简体   繁体   English

从服务器调用 API 时出现“无法解析远程名称”错误

[英]“The remote name could not be resolved” error when calling API from server

On my website I have some calls to an API.在我的网站上,我调用了一些 API。

In client side, with AJAX, it works perfectly but from server side (MVC and C#) I'm getting the following error:在客户端,使用 AJAX,它可以完美运行,但从服务器端(MVC 和 C#)我收到以下错误:

The remote name could not be resolved 'api.website.com'无法解析远程名称“api.website.com”

This is the code that calls the API:这是调用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 设置上,一旦修复,它就可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 recaptcha无法解析远程名称:“ api-verify.recaptcha.net” - recaptcha The remote name could not be resolved: 'api-verify.recaptcha.net' 无法解析远程名称:'sandbox.api.mastercard.com' - The remote name could not be resolved: 'sandbox.api.mastercard.com' 无法解析远程名称:“ api-3t.sandbox.paypal.com” - The remote name could not be resolved: 'api-3t.sandbox.paypal.com' 远程名称无法解析:'api.twitter.com'Linq to Twitter - The remote name could not be resolved: 'api.twitter.com' Linq to Twitter SMTP远程名称无法解析 - SMTP Remote name could not be resolved 无法解析远程名称 - webclient - The remote name could not be resolved - webclient 检查网站是否运行错误“无法解析远程名称” - check if a website is working error“The remote name could not be resolved” Azure Cosmos DB 创建数据库时出错:无法解析远程名称 - Azure Cosmos DB error in creating database: The remote name could not be resolved 创建 blob 容器时无法解析远程名称 - The remote name could not be resolved when creating blob Container .NET Core调用WCF:无法解析服务器名称或地址错误 - .NET Core call WCF: The server name or address could not be resolved error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM