Originally posted on: http://geekswithblogs.net/foxjazz/archive/2019/10/21/http-client-gets-data-from-service-call.aspx
using (var client = new HttpClient())
{
string contentType = "application/json";
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(contentType));
var response = client.GetAsync(baseuri).Result;
if (response.IsSuccessStatusCode)
{
var responseContent = response.Content;
// by calling .Result you are synchronously reading the result
string responseString = responseContent.ReadAsStringAsync().Result;
eveHome = JsonConvert.DeserializeObject<EveHome>(responseString);
}
}