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.
Here is my Xamarin 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<AndroidMapCompanyViewModel>(json);
}
return androidMapCompanyViewModel;
}
I am getting the following error:
Error: ConnectFailure (Network is unreachable)
With the following URL:
"http://localhost:22101/api/MapCompanyAPI/1"
When clicking on the details for the error, the following is at the top of the list:
System.ArgumentException: Illegal characters in path.
If I open up my browser, I can successfully connect to the URL.
Can I please have some help to de serialize the json data from my localhost url?
Thanks in advance