Ive created a web Api which fetches data from my Sql Server database
I ran this Api through a web browser and it fetches my data very well, I ran it in postman tool its Ok(http:http://172.26.44.65/api/studentservices)
Ive published it in IIS and created an application which run fine.
I have now created a Xamarine forms application, for accessing it via my mobile phone and did every thing required as per the tutorials i see here on the web, However when it reaches accessing the web api to fetch data, i get the following error:
System.Net.WebException: failed to connect to /172.26.44.65 (port 80) after 120000ms: connect failed: ENETUNREACH (Network is unreachable)
What causes this error?
Nkabirwa IsmailPosted Aug 25, 2019, 6:01 AM
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
GetStudents();
}
private async void GetStudents()
{
HttpClient client = new HttpClient();
// var response = await client.GetStringAsync("http://productsdemoapp.azurewebsites.net/api/products");
// var response = await client.GetStringAsync("http://localhost/STUDENTSERVICES/api/student");
var response = await client.GetStringAsync("http://172.26.44.65/studentservices/api/student");
// http://localhost/ProductsApp/
//var response = await client.GetStringAsync("http://192.168.8.100:3574/api/Products");
//wano
// var products = JsonConvert.DeserializeObject
>(response);
var students = JsonConvert.DeserializeObject
>(response);
StudentListView.ItemsSource = students;
//give a name to our list as ProductsListView
}
}
}