【发布时间】:2020-04-16 17:49:48
【问题描述】:
我尝试使用http://api.reseller.world/#api-Domain-GetInfo获取域 whois 信息,收到此错误:远程服务器返回错误:(400) Bad Request。
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string apiAddress = "https://api.reseller.world/v1.4/dms/domain/{0}";
string api = string.Format(apiAddress, domainName);
var request = (HttpWebRequest)WebRequest.Create(api);
request.Headers.Add("Authorization", "Bearer token");
request.Method = HttpMethod.Get.ToString();
request.Accept = "application/json";
request.ContentType = "application/json; charset=UTF-8";
HttpWebResponse response;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException we)
{
var resp = we.Response as HttpWebResponse;
return null;
}
【问题讨论】:
-
查看您的链接。有可选参数。所有其他参数都是必需的,并且您缺少大部分必需参数。 400 错误表明服务器不喜欢 hedaders。
-
@jdweng 我做的就像我们这里的api.reseller.world/#api-Domain-GetInfo 一样,可以得到我错过的发送
-
新链接说400是缺少参数之一。
-
@jdweng 请写下我错过的内容
标签: c# .net api httpwebrequest webrequest