User-1147271863 posted
I'm having trouble with resolving the View(Movies). I have debugged this and the problem stems from where I try and add to the list after attempting to deserializing it.
The debugger says newtonsoft.json.jsonserlizationexception cannot deserialize the current json object
using System;
using System.Collections.Generic;
using System.Data;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using pdrake.Models;
namespace pdrake.Controllers
{
public class MovieApiController : Controller
{
public List<Root> Movies { get; set; }
public async Task<ViewResult> GetMovies()
{
using (var httpClient = new HttpClient())
{
using (var response = await httpClient.GetAsync("https://api.themoviedb.org/3/discover/movie?api_key=my_key"))
{
string apiResponse = await response.Content.ReadAsStringAsync();
Movies = JsonConvert.DeserializeObject<List<Root>>(apiResponse);
return View(Movies);
}
}
}
}
}