Report this

What is the reason for this report?

Dynamic DNS with v2 API (Bash script, using Curl in Ubuntu)

Posted on August 21, 2014

Using the following Bash snippet (with variables defined outside of this block) I am not able to update a dns record.

echo content="$(curl -H "Authorization: Bearer $api_key" -H "Content-Type: application/json" \
                 -d '{"type": "A", "name": "'"$record_id"'", "data": "'"$ip"'"}' \
                 -X POST "https://api.digitalocean.com/v2/domains/$domain_id/records/$record_id")"

If I remove $record_id from the URL, it just creates a new record. If I use the A entry name/subdomain “home” in my case, it says record not found, same if I try the numeric ID for the record.

How should I modify this call to properly update the IP of a DNS record?

This is based off the script here (in latest comment from author):

https://gist.github.com/glpunk/8679208

When I run it (as posted on github), it just creates a new record every time, not an update.



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!

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.

FYI This was solved, I added a fix to the github comment thread.

The issue was changing POST to PUT, and specifying the numeric record_id in the curl URL.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.