Hi there I’m using this script to update a record in “data” field, but it wont change anything .
PUBLIC_IP=`curl -s http://icanhazip.com`
echo "TOKEN $TOKEN"
IP="$PUBLIC_IP"
echo "IP $IP"
curl -X PUT -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" -d '{"data":"$IP"}' "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD"
curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD"
It gives me this error
IP 181.66.127.36
{"id":"unprocessable_entity","message":"IP address did not match IPv4 format (e.g. 127.0.0.1)."}{"domain_record":{"id":3304482,"type":"A","name":"periquita","data":"23.95.118.100","priority":null,"port":null,"weight":null}}
And if I execute withour qoutes around $IP, like this:
curl -X PUT -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" -d '{"data":$IP}' "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD"
goes straigt but no changes.
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!
You need to escape the quotes in the JSON string so that they don’t get parsed by bash:
curl -X PUT -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" -d '{\"data\":\"$IP\"}' "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD"
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.