I want to use TheMovieDb Api in a Windows Store app.
For Windows Phone 8, I used a WebClient :
WebClient client = new WebClient();
client.DownloadStringCompleted += client_DownloadStringCompleted;
client.DownloadStringAsync(new Uri("http://api.themoviedb.org/3/search/movie?api_key=" + key + "&query=" + movieName));
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
RootObject resultat = JsonConvert.DeserializeObject<RootObject>(e.Result);
idMovie = resultat.results.FirstOrDefault().id.ToString();
}
}
How can I do that in a Windows 8 app ?
I tried
HttpClient http = new System.Net.Http.HttpClient();
string response = await http.GetStringAsync("http://api.themoviedb.org/3/search/movie?api_key=" + key + "&query=" + movieName);
return response;
But I get an error:
Response status code does not indicate success : 406(Not Acceptable)
Thanks
EDIT :
Ok, I had to add
http.DefaultRequestHeaders.Add("accept", "Application/JSON");