JSONConvert not returning any values from list using deserializeobject function

Viewed 56

I have code that is working on one of my aspx.cs pages but not this one. The issue is that The JsonConvert.DeserializeObject is returning a list of null values. This is the code

private async Task getProj(List<ProjectsObj> temp)
{
    using (var client1 = new HttpClient())
    {
        client1.BaseAddress = new Uri("http://localhost:57578/");
        client1.DefaultRequestHeaders.Accept.Clear();
        client1.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
        HttpResponseMessage resp = await client1.GetAsync("api/projects").ConfigureAwait(false);
        if (resp.IsSuccessStatusCode)
        {
            dynamic result = await resp.Content.ReadAsStringAsync();
            List<ProjectsObj> root = JsonConvert.DeserializeObject<List<ProjectsObj>>(result);
            foreach (ProjectsObj proj in root)
            {
                temp.Add(proj);
            }
        }
    }
}
0 Answers
Related