1
I created a WEB API on Asp.net that is hosted on a web server. This WEB API accesses a table in SQL Server where I have a table called Products with Id, name, description and Price, I ran the tests via POSTMAN and it is working correctly, but when I try to consume the method to bring a specific product via Xamarin application in visual studio
I get the following error message in interrupt mode
application in Interrupt mode
Unhandled Exception:
System.Net.Http.HttpRequestException: <Timeout exceeded getting exception details>
Below is my code to bring a specific product accessing the API on the server
public class DataService
{
public async Task<List<Produto>> GetProductAsync(string NomeProduto)
{
using (var client = new HttpClient())
{
string url = "http://ProdutosAPI.servidor.com/api";
try
{
var uri = url + "/" + NomeProduto.ToString();
HttpResponseMessage response = await client.GetAsync(uri);
var ProdutoJsonString = await response.Content.ReadAsStringAsync();
var Produto = JsonConvert.DeserializeObject<List<Produto>>(ProdutoJsonString);
return Produto;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
First translate your question into Portuguese because it is in
stackoverflow em português
– Edu Mendonça
show! Now just wait until they help you. Success!!!
– Edu Mendonça
Which version of Visual Studio and which version of Xamarin?
– William John Adam Trindade
Friend, if in POSTMAN works and in your device does not, check the internet permissions of the application. Source: Permissions in Xamarin
– Gustavo Santos
Hello, Where is your application running? You should check the API access from the device that runs the application. Try to access the API address via device browser / emulator and if you cannot check the network settings (firewall, proxy, topology etc.) of your service.
– Ramon Barbosa
Visual studio 2017 - I’m getting this message Unhandled Exception: System.Net.Http.Httprequestexception: An error occurred while sending the request
– Luiz Fernando