API for changing DNS returns success but IP address doesn't change

What is the name of the domain?

jayinchina.net

What is the error number?

No error it returns success.

What is the error message?

There is no error.

What is the isssue you’re encountering

When changing my A record DNS using API it returns success but the IP doesn’t change.

What steps have you taken to resolve the issue?

I am calling the API for updating my DNS record, with a global API key or zone API key both return the same, and the result is “success”:true. The rest of the return looks good except the “content” tag is still the old IP and it does not actually update my IP. In the dashboard it is still the old IP.

Exactly as on this page, the response is also identical except I don’t have comments or tags: Cloudflare API Documentation

What feature, service or problem is this related to?

DNS records

What are the steps to reproduce the issue?

I am calling the API for updating my DNS record, with a global API key or zone API key both return the same, and the result is “success”:true. The rest of the return looks good except the “content” tag is still the old IP and it does not actually update my IP. In the dashboard it is still the old IP.

Exactly as on this page, the response is also identical except I don’t have comments or tags: Cloudflare API Documentation

Screenshot of the error

Can you show the code for the API call you are making.

Sure, the script isn’t mine originally but I’m a software engineer and once it didn’t work I read the docs and I cannot see anything wrong with it. The original script is here: cloudflare-ddns-updater/cloudflare-template.sh at main · K0p1-Git/cloudflare-ddns-updater · GitHub

The line in question is:

update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$record_identifier" \
                     -H "X-Auth-Email: $auth_email" \
                     -H "$auth_header $auth_key" \
                     -H "Content-Type: application/json" \
                     --data "{\"type\":\"A\",\"name\":\"$record_name\",\"content\":\"$ip\",\"ttl\":$ttl,\"proxied\":${proxy}}")

In this instance $zone_identifier is Zone ID from my dashboard, $record_identifier is worked out using my zone id and record name and is returning correctly or it would be exiting, $auth_email is my cloudflare email, I have tried both a zone token with Zone.DNS permission and my Global API key for $auth_key. Both return success true. $record_name is jayinchina.net, $ttl = 3600 (it is 1 in my control panel but also does not change) and $proxy is false.

I do not understand why this seems to be working, all the ducks line up. Thanks.

It’s worth noting the same zone id and token worked for this script which fetched me an SSL certificate using DNS: dnsapi · acmesh-official/acme.sh Wiki · GitHub

Try @, otherwise you may have created jayinchina.net.jayinchina.net

;; ANSWER SECTION:
jayinchina.net.jayinchina.net. 300 IN	A	36.xx.xx.xxx

[add] Seems you have a wildcard so that explains the DNS response above.

1 Like

That’s interesting, where are you seeing that. When I look at my dashboard it shows a record for *, jayinchina.net and www. My other domain I have never used a script to update points where I expect it to.

Anywho, thanks for your help, it turns out I am a goober, I took a fork of the script I linked which tried to allow for multiple records which clearly doesn’t work, when I took the original script and amended it myself to work for multiple records it works fine!

Thanks again for your help!

Sorry mean my other domain shows the listing only for the domain.tld same as I was doing.

Jusy FYI @ returns does not exist and so does www even though I’m looking at www.

record=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records?type=A&name=$record_name" \
						  -H "X-Auth-Email: $auth_email" \
						  -H "$auth_header $auth_key" \
						  -H "Content-Type: application/json")

For anyone in future driving by here, the name has to be fully qualified, so www.jayinchina.net gets me the www record and *.jayinchina.net gets me the * record. All is working now.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.