Getting “Unable to connect to the remote server” When I call WebAPI Url (C#)
-
Below Code which I have tried:
NetworkCredential myCred = new NetworkCredential("xxxxx@xx.xxx.xxx", "xxxxxxxx");
using (var handler = new HttpClientHandler { Credentials = myCred })
{
HttpClient client = new HttpClient(handler);
client.BaseAddress = new Uri("https://xxxxx.xxx.xx:2601/api/getallprices");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(client.BaseAddress);
HttpWebResponse WebResp = (HttpWebResponse)request.GetResponse();
}Here when I tried to get response from request url, it throws an error
"Unable to connect to remote server"...
Can please anyone help me out to solve this error !!
-
Below Code which I have tried:
NetworkCredential myCred = new NetworkCredential("xxxxx@xx.xxx.xxx", "xxxxxxxx");
using (var handler = new HttpClientHandler { Credentials = myCred })
{
HttpClient client = new HttpClient(handler);
client.BaseAddress = new Uri("https://xxxxx.xxx.xx:2601/api/getallprices");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(client.BaseAddress);
HttpWebResponse WebResp = (HttpWebResponse)request.GetResponse();
}Here when I tried to get response from request url, it throws an error
"Unable to connect to remote server"...
Can please anyone help me out to solve this error !!
The URL is wrong, or the port is wrong, or one of the firewalls between the client and the server is blocking the request. You'll need to look at the details of the exception and debug the connection. We can't do that for you. For example, if the error says "the target machine actively refused", that normally points to a firewall. If it's a timeout, then the URL or port is wrong.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer