مهدی نبوی
مهدی نبوی

Reputation: 461

The remote server returned an error: (400) Bad Request. api.reseller.world

I try to get domain whois info by using http://api.reseller.world/#api-Domain-GetInfo, got this error: The remote server returned an error: (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;
}

Upvotes: 0

Views: 2105

Answers (2)

user13337746
user13337746

Reputation:

I read your code and api documention and find a different in the URL you used

https://api.reseller.world/v1.4/dms/domain/{0}

that after formating somting look like this

https://api.reseller.world/v1.4/dms/domain/something.something

And documention url

https://api.reseller.world/v1.4/dms/domain/:domainName

After formating

https://api.reseller.world/v1.4/dms/domain/:something.something

Different is ":"

But I have no api key to test this ideia

Or may be you need to set UserAgent Property of your's request. As far as I can remember, C# does not set this property.

Upvotes: 0

jdweng
jdweng

Reputation: 34429

See image below "Required Parameter Missing"

enter image description here

Upvotes: 1

Related Questions