I have some problems with connecting to my REST web service from my Windows store app (side-loaded) on tablet with windows 8.1.
Web service is publish on company server and device belongs to domain so both devices are on the same network (intranet). I’ve tried different capabilities:
My code is something like that:
using Windows.Web.Http;
private async Task SendRegistrationData()
{
using (var client = new HttpClient())
{
var baseAddress = new Uri(@"http://serverName:88/Device/RegisterDevice");
var msg = new HttpRequestMessage(new HttpMethod("POST"), baseAddress);
var serializedDevice = JsonConvert.SerializeObject(CurrentDevice.Instance);
msg.Content = new HttpStringContent(serializedDevice);
msg.Content.Headers.ContentType = new HttpMediaTypeHeaderValue("application/json");
client.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
HttpResponseMessage response = null;
try
{
response = await client.SendRequestAsync(msg);
await Logger.LogError("Registration data were sent");
}
catch(Exception ex)
{
Logger.LogError("Communication errors", ex, 5);
Logger.LogError("HResult: " + ex.HResult.ToString());
var tmp = new CustomMessageBox();
tmp.ShowMessage("Communication error: " + ex.Message , " Communication error ");
}
}
}
Important thing!
When I test my web service from the same device using ‘Advanced rest Client’ (chrome browser add-on) everything works just fine. I’ve problems only with my LOB Windows Store app. Any suggestions?
Regards
EDIT: Error message: Cannot establish Connection with server
HResult: -2147012889
EDIT 2 Something new just happend. I've install fiddler like @Jon said in the last comment and something very weird happend.
start fiddler (without any additional configuration)
start my windows store app and it communicates with web service, everything works just fine
close fiddler
windows store applications can not connect with web service!?
Any clue?
I thought that those two capabilities are enough: Private Networks with Enterprise authentication - I was mistaken.
Despite of that the web service is at the company server, and my windows device was added to company domain I have to set another capability at windows store manifest file: Internet(Client)
And right now everything works just fine
Regards, Marcin