简体   繁体   中英

“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 'api.website.com'

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(@"http://api.website.com/functions/email", data);

Any help would be very much appreciated.

正如@neuhaus 所写,问题出在 DNS 设置上,一旦修复,它就可以正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM