I want to take the data from the web api service of the Gutenberg project and make a site in an mvc structure. But I encountered an error while pulling the data. I need help. Web API: https://gutendex.com/
`
public async Task<IActionResult> GetBooksFromApi()
{
var books = new List<BookModel>();
using (var httpClient = new HttpClient())
{
using (var response = await httpClient.GetAsync("https://gutendex.com/books"))
{
string apiResponse = await response.Content.ReadAsStringAsync();
books = JsonConvert.DeserializeObject<List<BookModel>>(apiResponse);
}
}
return View(books);
}
`
public class BookModel
{
public int id { get; set; }
public string Title { get; set; }
public string[] Subjects { get; set; }
public string[] Authors { get; set; }
public string[] Translators { get; set; }
public string[] Bookshelves { get; set; }
public string[] Languages { get; set; }
public bool Copyright { get; set; }
public string Media_Type { get; set; }
public string Formats { get; set; }
public int Download_Count { get; set; }
}
}
I wanted to use the json data received using the Newtonsoft package on my site, but I am getting an error in the conversion.