I have a service that returns some data that I am displaying on a DataGrid. I have an OData endpoint that I am trying to hook up. Everything is good except when I try to call ReadAsync to read the response, the application hangs and never returns. I have set up Fiddler and am able to see the request going to the OData service with the correct querystring and the data comes back like this:
[{"speciesId":"dd9919c3-c8a2-429d-8141-27f2b0904eff","name":"Avian111","isActive":false,"breeds":[],"patients":[]},{"speciesId":"245ba26d-b545-478e-9ddf-2a348e54c6f4","name":"Canine","isActive":true,"breeds":[],"patients":[]}]
I have a service class that follows the pattern in the OData example:
partial void OnGetSpecies(HttpRequestMessage requestMessage);
public async Task<ODataServiceResult<Species>> GetSpecies(string filter = default(string), int? top = default(int?), int? skip = default(int?), string orderby = default(string), string expand = default(string), string select = default(string), bool? count = default(bool?))
{
var uri = new Uri("https://localhost:8001/api/species");
uri = uri.GetODataUri(filter: filter, top: top, skip: skip, orderby: orderby, expand: expand, select: select, count: count);
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
OnGetSpecies(httpRequestMessage);
var response = await _httpClient.SendAsync(httpRequestMessage);
var result = await response.ReadAsync<ODataServiceResult<Species>>();
return result;
}
and I have a LoadData method on the razor component that is hooked to the grid:
private async Task LoadData(LoadDataArgs args)
{
_isLoading = true;
var result = await SpeciesService.GetSpecies(filter: args.Filter, top: args.Top, skip: args.Skip, orderby: args.OrderBy, count: true);
_species = result.Value.AsEnumerable<Species>();
_count = result.Count;
_isLoading = false;
}
Everything works great until it gets to this line of code:
var result = await response.ReadAsync<ODataServiceResult>();
Once I hit F10 in the debugger on that line, it never returns and the grid just sits there empty.
Does anyone know what I need to do? I feel like I might just be missing some code where I configure the parsing or something.