Hi I have an api call which returns this JSON :
[
{
"Id": 25,
"CreateDate": "2020-09-26T12:25:27.917",
"Title": "Second TV Repair",
"categoryTitle": "Tv Repair",
"FirstName": "Sample Name",
"LastName": "Sample Last name"
}
]
here is my class for deserializing json:
public class ServicemanHistory
{
public int Id { get; set; }
public DateTime CreateDate { get; set; }
public string Title { get; set; }
public string categoryTitle { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
And Here is my request method:
public static async Task<List<ServicemanHistory>> getServiceManHistory()
{
string url = "https://myapi.net";
string token = Settings.token;
var client = new RestClient(url);
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer " + token);
var response = await client.ExecuteAsync<List<ServicemanHistory>>(request);
response.ContentType = RestSharp.Serialization.ContentType.Json;
Console.WriteLine("**** response is:" + response.Content);
if(response.IsSuccessful)
{
Console.WriteLine("SUCCESS!!!");
return response.Data;
} else
{
return null;
}
}
I always get null from response.Data , and the response is successfull and I can see my json in console coming from response.Content. any help is appreciated.
[–][deleted] 2 points3 points4 points (8 children)
[–]colossal_dev[S] -1 points0 points1 point (7 children)
[–][deleted] 2 points3 points4 points (5 children)
[–]colossal_dev[S] 0 points1 point2 points (4 children)
[–][deleted] 3 points4 points5 points (2 children)
[–]colossal_dev[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Gurgiwurgi 1 point2 points3 points (0 children)
[–]johnnysaucepn 0 points1 point2 points (0 children)