user3378165 user3378165 - 1 year ago 174
C# Question

"The remote name could not be resolved" error when calling API from server

On my website I have some calls to an API.

In client side, with AJAX, it works perfectly but from server side (MVC and C#) I'm getting the following error:

The remote name could not be resolved ''

This is the code that calls the API:

JsonSerializerSettings settings = new JsonSerializerSettings();
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
var data = JsonConvert.SerializeObject(email);
WebClient client = new WebClient();
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var resp = client.UploadString(@"", data);

Any help would be very much appreciated.

Answer Source

As @neuhaus wrote, the problem was due to a DNS setting, once it had been fixed it worked fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download