Reputation: 183
At the moment I am trying to simulate my Android application. The application developed is using xamarin.forms and works on both Android and iOS.
My problem is when doing restful request using httpClient. At the moment I am using localhost. When running on iOS I have no problems, however Android returns the following exception:
This is the code that makes the problem:
var request = new HttpRequestMessage(HttpMethod.Post, sharedURL.baseUrl + "connect/token");
request.Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
["grant_type"] = "password",
["username"] = username,
["password"] = password,
["scope"] = "offline_access"
});
var response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead);
I believe it could have something to do with https, as my restfull services are not set up with https. However I am not able to disable this on Android. Any clues?
Upvotes: 2
Views: 3199
Reputation: 4309
Double check that the device has internet connectivity and is able to access basic sites. This happens for me when I disable Data & Wifi and then attempt to do an http call.
Upvotes: 1
Reputation: 512
I was with the same problem on my release version (debug was working fine). Checking "Internet" permission on my droid project did the trick.
Upvotes: 3