Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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");
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.