Hi guys,
I have created a demo WebApi and hosted it on Azure. When I test in the browser and with Fiddler, all the HTTP verbs work.
The problem is when I try to use it in my Windows Phone application, I get a 404 error for any request. Below is the code I wrote.
protected async override void OnNavigatedTo(NavigationEventArgs e) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://apidemov2.azurewebsites.net/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync("api/books"); if (response.IsSuccessStatusCode) { //some code } } }
The code is returning false for IsSuccessStatusCode and returning 404. If I test the uri in Fiddler and the browser, it returns the data.
Please help. Thanks.