Hi Magi,
i use this code without problems:
private async Task<AsyncObservableCollection<ContinentModel>> GetContinentModels()
{
AsyncObservableCollection<ContinentModel> ReturnContinentModels = new AsyncObservableCollection<ContinentModel>();
try
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Add("Accept", "application/json;charset=UTF-8");
using (HttpResponseMessage HttpResponseMessage = await httpClient.GetAsync(string.Concat(_RootUrl, ""), HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false))
{
if (HttpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK)
{
using (HttpContent HttpContent = HttpResponseMessage.Content)
{
string MyContent = await HttpContent.ReadAsStringAsync();
var root = JsonConvert.DeserializeObject<RootObject>(MyContent);
ReturnContinentModels = new AsyncObservableCollection<ContinentModel>(root.products);
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return ReturnContinentModels;
}