User379720387 posted
private IEnumerable<RecordDetail> recordDetails = new List<RecordDetail>();
That is what it took, to get the data.
This made my code run however it turns out that json data from the controller was not being populated.
A Microsoft engineer (Ignite one-on-one consultation) has suggested a potential race condition and a remedy.
His suggestion was to separate the data retrieval (controller) from the serialization. And this code is below.
I can report now that data now shows what I was hoping to see in the first place.
However, the Deserialize statement now has a squiggle with a complaint about round hole, square peg:
Cannot implicitly convert type System.Collections.Generic.List.Model.RecordGrid to Model.RecordGrid
var httpClient = _clientFactory.CreateClient("ServerAPI");
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
var json = JsonSerializer.Serialize(records);
//var y = JsonSerializer.Deserialize<Service>(json);
var content = new StringContent(json);
string errorMessage = null;
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
var response = await httpClient.GetAsync($"{baseUrl}/api/Record/ByProvider/22");
var data = await response.Content.ReadAsStringAsync();
RecordGrid result = new RecordGrid();
//snackMsg = String.Format("{0} records retrieved", records.Count());
if (response.IsSuccessStatusCode)
{
result = JsonSerializer.Deserialize<List<RecordGrid>>(data);
}
else
{
errorMessage = data;
}
I suspect my problem lies here, but dont know how to remedy that.
And here is RecordGrid:
public class RecordGrid
{
public int ClientId { get; set; }
public int ProviderId { get; set; }
public string CName { get; set; }
public string Location { get; set; }
public string State { get; set; }
public string OName { get; set; }
public int TxnCount { get; set; }
}