I'm trying to add an A record to a domain using GoDaddy's API, but I'm getting a 422 (Unprocessable Entity) response error in the console of my browser. However, when I test the request using GoDaddy's documentation on https://developer.godaddy.com/doc#!/_v1_domains/recordAdd/ArrayOfDNSRecord I get a 404 response error with the body below:
Body of error response:
{
"code": "UNKNOWN_DOMAIN",
"message": "The given domain is not registered, or does not have a zone file",
"name": "_Class"
}
The domain I'm trying to add the A record to definitely exists, so I don't know why it would return a 404 error. I have no problem retrieving all of the A records belonging to the domain using a GET request, but when I try to run the PATCH request below I get the errors.
Is there something wrong with GoDaddy's API or is there an issue with how I'm structuring my request?
PATCH request that returns error
$.ajax({
type: 'PATCH',
url: 'https://api.godaddy.com/v1/domains/{domain}/records',
data: {
'records': [{
'type': 'A',
'name': 'test',
'data': '255.255.255.255'
}]
},
headers: {
'Authorization': 'sso-key {API_KEY}:{API_SECRET}'
},
success: function(body) {
console.log(body);
}
});
GET request that works fine
$.ajax({
type: 'GET',
url: 'https://api.godaddy.com/v1/domains/{domain}/records/A',
headers: {
'Authorization': 'sso-key {API_KEY}:{API_SECRET}'
},
success: function(body) {
$.each(body, function(i, v) {
$('body').append('<p>Name: ' + v.name + '<br/>Data: ' + v.data + '</p>');
});
}
});
I just experienced this same issue and the problem for me was caused by combining their "OTE" and "Production" services.
Since you're making the query to api.godaddy.com
and not api.ote-godaddy.com
, you need to be using a "Production" key and secret, and have your site operating in a production environment as opposed to GoDaddy's Operating Test Environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With