RestRequest in Xamarin for Android
I have the same problem as here: http://forums.xamarin.com/discussion/18907/system-net-webexception-error-connectfailure-network-is-unreachable
I have upgraded Xamarin to v3 and my previously running application no longer has access to any network, not even localhost. I can see that full network access is enabled in the deployed app on my Android 4.3 Galaxy SIII while the emulator is running. I tried both the RestClient shown below and the HttpWebRequest with the same results. Even when using a new project using this recipe http://developer.xamarin.com/recipes/android/web_services/consuming_services/call_a_rest_web_service/ gives the same result. As far as I know, everything is updated to the current one.
var client = new RestClient("http://192.168.0.111");
var request = new RestRequest("api/item/getitems", Method.GET);
var response = _client.Execute(request);
if (response.ResponseStatus == ResponseStatus.Completed && response.StatusCode != HttpStatusCode.InternalServerError)
{
results = JsonConvert.DeserializeObject<IEnumerable<Item>>(response.Content).ToList();
}
else
{
throw new Exception(response.ErrorMessage);
}
The result is always "Error: ConnectFailure (network unavailable)"
Edit: I upgraded Xamarin to 3.11, all packages are on the current one, and now wireless is working, but when going over mobile, it returns "System.Net.WebException: Error: ConnectFailure (Connection reject)".
source to share