title: Issues with Xamarin Forms retrieving json from webservices / rest api
body: <p>I am having trouble retrieve data from a webservice using a PLC project in Xamarin forms.
  I have tried both the WebRequest and HttpClient but get various exceptions. I have also tried 
  to run the code from this sample:  </p>
  
  <ol>
  <li><p>ConnectFailure (Network is unreachable)</p>
  
  <pre><code>HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create ("http://localhost:3000/profile/contacts");
          webRequest.UseDefaultCredentials = true;
          webRequest.Method = "GET";
          webRequest.Accept = "application/json";
          webRequest.ContentType = "application/json";
          webRequest.BeginGetResponse ((ar) =&gt; {
              var request = (HttpWebRequest)ar.AsyncState;
              try {
                  using (var response = (HttpWebResponse)request.EndGetResponse (ar)) {                              
                      var s = response.GetResponseStream ();
                  }
              } catch (Exception ex) {
                  var xy = ex;
              }
  
          }, webRequest);
  </code></pre></li>
  <li><p>ConnectFailure (The requested address is not valid in this context) </p>
  
  <pre><code>            var client = new System.Net.Http.HttpClient ();
              client.BaseAddress = new Uri("http://localhost:3000/");
              client.DefaultRequestHeaders.Clear ();
              client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
              var response = await client.GetStringAsync ("profile/contacts");
  </code></pre></li>
  </ol>
  
  <p>I have also tried to run the code from this sample: <a href="https://github.com/conceptdev/xamarin-forms-samples/tree/master/HttpClient/HttpClientDemo" rel="nofollow noreferrer">https://github.com/conceptdev/xamarin-forms-samples/tree/master/HttpClient/HttpClientDemo</a>
  Which throws a namesresolutionfail exception when trying to make a request.</p>
  
  <pre><code>var client = new System.Net.Http.HttpClient ();
                  client.BaseAddress = new Uri("http://api.geonames.org/");
                  var response = await client.GetAsync("earthquakesJSON?north=44.1&amp;south=-9.9&amp;east=-22.4&amp;west=55.2&amp;username=bertt");
                  var earthquakesJson = response.Content.ReadAsStringAsync().Result;
                  var rootobject = JsonConvert.DeserializeObject&lt;Rootobject&gt;(earthquakesJson);
                  return rootobject.earthquakes;
  </code></pre>
  
  <p>I have tested my rest api (written in Node.Js) and it is returning data as expected.</p>