Hey guys!
I developed a ASP.NET Web Api (2.2) with odata support. The API works fine, I use fiddler to get, post stuff and the api handles everything fine.
Now I'm trying to write a C# library that consumes the API. Now I used to have a API without odata support and the following code works just fine :
var url = "Support/Tickets";
HttpResponseMessage response = client.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
var list = response.Content.ReadAsAsync<List<Tickets>>).Result;
}
(client here is a System.Net.Http.HttpClient object)
However, since I implemented the odata solution, the JSON returned from the API is changed :
{
"odata.metadata":"http://url.to/Support/$metadata#Tickets","value":[
{
}
]
}
Now the bold line is new and causes the line
var list = response.Content.ReadAsAsync<List<Tickets>>).Result;
to fail. The fact that the line fails I understand, but I can't figure out what way to handle the new JSON response correctly. Do I need to use some kind of odata deserializer or something?
Thanks!
Eduard