API V2 PHP Domain update says domain record is not included

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

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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?