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>');
});
}
});
PATCH
request? I have found examples ofPUT
requests that I assume work, but they either update an existing record or replace the whole zone file. I want to add a new record without the possibility of breaking existing records. Thanks! – Reismandomain
field in the request as well. I tried it and still get the same error. – ReismanPATCH
request that just sends the array of records as the data. (Not wrapped in an object with arecords
field.) I tried this as well and still get the same error. – Reisman