It sounds like you're dealing with a collection so try:
var jsonContent = JsonConvert.DeserializeObject<List<JiraResponse>>(jsonString);
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
I'm using Jira API to pull date from Jira and populate on Excel
Problem - I'm not to deserialize the response
I used this to create the response object
https://json2csharp.com/
Verified Json using this http://json.parser.online.fr/
can comeone please help me with a reference link or sample code
private static async Task SearchJira()
{
try
{
string apiUrl = @"https://URL/rest/api/3/search?jql=project=ProjectName&maxResults=10";
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("GET"), apiUrl))
{
var base64authorization =
Convert.ToBase64String(Encoding.ASCII.GetBytes("emailId:CU2NhBYhT2Di48DA9"));
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {base64authorization}");
var response = await httpClient.SendAsync(request);
// I can Json response in this variable
var jsonString = await response.Content.ReadAsStringAsync();
// How to populate the response object
var jsonContent = JsonConvert.DeserializeObject<JiraResponse>(jsonString);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
Now I need to populate the list so that I can intern populate my excel and move forward with code...
Appreciate the help
It sounds like you're dealing with a collection so try:
var jsonContent = JsonConvert.DeserializeObject<List<JiraResponse>>(jsonString);
Hi SwatantraSingh-2674,
Please try to use string instead of var, as now it inferred the type as Task<string>.
Change var jsonString = await response.Content.ReadAsStringAsync();
To
String jsonString = await response.Content.ReadAsStringAsync();
Or
String jsonString = response.Content.ReadAsStringAsync().Result;
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.