0
votes

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Movie]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path 'Movies', line 2, position 13.

1
public async Task<List<Movie>> GetMoviesAsync() { //string authToken = null; using (HttpClient httpClient = new HttpClient()) { return JsonConvert.DeserializeObject<List<Movie>>( await httpClient.GetStringAsync(uri) ); } }Saif Ali

1 Answers

1
votes

You are trying to deserialize JSON into an array type but your JSON is not of type array.