I am trying to make an API call to a server where the response is in JSON format and it is extremely lengthy. I think that the limits of a string cannot hold the entire response, as I am only getting part of it. I'm not sure how to retrieve the whole response, as i need to read certain parts throughout the response (there is a repeating structure for each location where I need to find data, for example the name). Here is the code I have so far, with private info being excluded:
using (var httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri("ADDRESS HERE");
httpClient.DefaultRequestHeaders.Add("Api-Key", "API KEY HERE");
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/hal+json"));
var response = httpClient.GetAsync("locations/").Result;
string res = "";
using (HttpContent content = response.Content)
{
Task<string> result = content.ReadAsStringAsync();
res = result.Result;
}
How could I obtain the entire response? Do I need to parse it? And if so please point me in the right direction to documentation or other good answered questions. I am new to C# and API calls, but C# seemed to handle it the best in my situation. Thank you.