API V2 PHP Domain update says domain record is not included

  • Posted March 1, 2015

Hey there,

I have strange problem here.

I started writing script yesterday for updating a domain name, and it was working fine. But today I am getting error:

string(81) "{"id":"unprocessable_entity","message":"Record type is not included in the list"}" {"type":"A","name":"home","data":""}

This is the code:

  $ch = curl_init($request_uri);
  $headers = array(
    'Authorization: Bearer ' . file_get_contents('token.txt') );
  $rawdata = array(
  'type'      => 'A',
  'name'      => 'sub',
  'data'      => '',
  'priority'  => null,
  'port'      => null,
  'weight'    => null
  $postdata = json_encode($rawdata);

  $ch = curl_init();                    // initiate curl
  $url = ""; 
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_POST, true); 
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  $output = curl_exec ($ch); // execute
  curl_close ($ch); // close curl handle
  var_dump($output); // show output
  echo $postdata;//show what I am posting

There is no difference how I format the json POST request - it never detects the type and returns that error.

Any help will appreciated.

Thanks, Ivan


Ok, for me this API is not working properly.

Played around with domain update. When I request something from existing subdomain at

I got response {"domain_record":{"id":5625553,"type":"A","name":"home","data":"","priority":null,"port":null,"weight":null}}

And when I try to update the very same domain name I got not found! {"id":"not_found","message":"The resource you were accessing could not be found."} As described here:

How can the ID can’t be found as I am requesting to the very same URL?

Look for a commit to your API around 26-28 of February - before that everything was working fine.

Thanks, Ivan

Hey asb,

Thanks a lot for the comment.

Tried the code on both my localhost and a droplet here, and got the same result. Here is the specs- Localhost: Ubuntu 14.04.2 LTS 3.13.0-46-generic; Apache/2.4.7 (Ubuntu); PHP 5.5.9-1ubuntu4.6;

VPS: Ubuntu 12.04.5 LTS 3.2.0-24-virtual; PHP 5.3.10-1ubuntu3.15; Apache/2.2.22 (Ubuntu); varnishd (varnish-3.0.2 revision cbf1284);

Also there is a error in the posted code here - it should be without the first $ch

Can you share the code that is working for you? Well of course without the API and the actual request URL.

I also posted a question in stackoverflow as I thinking there should be something wrong with my code equivalent request from CLI is working, but nobody was able to tell this for now. You can see it here -

Many thanks, Ivan

Hi! Using nearly identical code, I am able to successfully create an A record. Could you describe the environment this is being run on at all? PHP version, OS, etc…

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi hozza,

At the end I think I used exec to run shell command through php, but later I gave up on php and I just have shell script which I use to update the DNS, here it is if that is going to help you:

#Description: Update IP address for A record on Digital Ocean API v2.
#Author: Ivan Denkov


#Retrieve current public IP
NIP=$(curl -s | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')

#Retrieve record IP
CIP=$(curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer '$TOKEN'' ""$DOMAIN_NAME"/records/"$RECORD_ID"" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["domain_record"]["data"]')
#echo [$(date +"%d-%m-%Y-%T")] "DO WAN IP: " $CIP  >> log.txt

#Compare past WAN IP and with current WAN IP
if [ "$NIP" != "$CIP" ]; then
   curl -X PUT -H 'Content-Type: application/json' -H 'Authorization: Bearer '$TOKEN'' -d '{"data":"'"$NIP"'"}' ""$DOMAIN_NAME"/records/"$RECORD_ID
  echo "IP is the same!"
exit 0;

I’m having the exact same issue… was there ever a solution to this?