title: Using WebClient to connect to Web Service
body: <p>I have coded a C# Web Api 2 web service application that uses JSON. I am now wanting to retrieve data from this web service into my Xamarin application.</p>
  
  <p>Here is my Xamarin code:</p>
  
  <pre><code>public AndroidMapCompanyViewModel GetMapCompanyFromWebService(string URL)
  {
      AndroidMapCompanyViewModel androidMapCompanyViewModel = new AndroidMapCompanyViewModel ();
      using (var webClient = new System.Net.WebClient()) 
      {
  
          var json = webClient.DownloadString(URL);
          androidMapCompanyViewModel = JsonConvert.DeserializeObject&lt;AndroidMapCompanyViewModel&gt;(json);
      }
      return androidMapCompanyViewModel;
  }
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Error: ConnectFailure (Network is unreachable)
  </code></pre>
  
  <p>With the following URL:</p>
  
  <pre><code>"http://localhost:22101/api/MapCompanyAPI/1"
  </code></pre>
  
  <p>When clicking on the details for the error, the following is at the top of the list:</p>
  
  <pre><code>System.ArgumentException: Illegal characters in path.
  </code></pre>
  
  <p>If I open up my browser, I can successfully connect to the URL.</p>
  
  <p>Can I please have some help to de serialize the json data from my localhost url?</p>
  
  <p>Thanks in advance</p>