How to Call the REST Service on a Windows Phone 8.1 Physical Device

I call the REST service in Windows Phone 8.1, it works in the simulator, but it does not work on the device. I'm stuck here, how to deal with it? See my code below:

 System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();

 HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:32002/XXXXX.svc/live_login?uname=abc&pwd=123");

 HttpResponseMessage response = await client.SendAsync(request);
 string data = await response.Content.ReadAsStringAsync();
 var dialog = new MessageDialog(data);
 await dialog.ShowAsync();
+4
source share
1 answer

The local address is not the same for your device and your PC.

When launched on the device, your code tries to connect to the recreation service on your phone, which obviously does not work.

+4
source

All Articles