调用 godaddy api 将指定的 DNS 记录添加到指定域时出现域错误
Doamin error when call godaddy api for add the specified DNS Records to the specified Domain
我正在使用 godaddy api 访问域。
我被推荐,
https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplace
我想在 Godaddy 的域中添加 CNAME。
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "sso-key {key}:{secret}");
var requestURl = "https://api.godaddy.com/v1/domains/mydomain.com/";
string body = "{\"data\": \"xxxxx.azurewebsites.net\",\"name\": \"xxxx\",\"type\": \"CNAME\"}";
var stringContent = new StringContent(body, Encoding.UTF8, "application/json");
var response = client.GetAsync(requestURl).GetAwaiter().GetResult(); ;
if (response.StatusCode == HttpStatusCode.Created)
{
}
}
但我收到错误代码 422。知道为什么会出现这些错误吗?
终于有答案了,
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "sso-key {key}:{secret}");
var requestURl = "https://api.godaddy.com/v1/domains/mydomain.com/";
var data = new
{
data= "xxxxx.azurewebsites.net",
name = "xxxx",
type = "CNAME",
ttl =3600
};
var body = JsonConvert.SerializeObject(data);
var stringContent = new StringContent("["+body+"]", Encoding.UTF8, "application/json");
var responseMessage = await client.PatchAsync(new Uri(requestURl), stringContent);
if (response.StatusCode == HttpStatusCode.Created)
{
}
}
我正在使用 godaddy api 访问域。 我被推荐, https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplace
我想在 Godaddy 的域中添加 CNAME。
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "sso-key {key}:{secret}");
var requestURl = "https://api.godaddy.com/v1/domains/mydomain.com/";
string body = "{\"data\": \"xxxxx.azurewebsites.net\",\"name\": \"xxxx\",\"type\": \"CNAME\"}";
var stringContent = new StringContent(body, Encoding.UTF8, "application/json");
var response = client.GetAsync(requestURl).GetAwaiter().GetResult(); ;
if (response.StatusCode == HttpStatusCode.Created)
{
}
}
但我收到错误代码 422。知道为什么会出现这些错误吗?
终于有答案了,
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "sso-key {key}:{secret}");
var requestURl = "https://api.godaddy.com/v1/domains/mydomain.com/";
var data = new
{
data= "xxxxx.azurewebsites.net",
name = "xxxx",
type = "CNAME",
ttl =3600
};
var body = JsonConvert.SerializeObject(data);
var stringContent = new StringContent("["+body+"]", Encoding.UTF8, "application/json");
var responseMessage = await client.PatchAsync(new Uri(requestURl), stringContent);
if (response.StatusCode == HttpStatusCode.Created)
{
}
}