I’m currently trying to write a PowerShell script (though this question is agnostic to my REST client / scripting language), so that I can regularly update a single A record (non-proxied).
Everything works just as expected, except that the ‘name’ property is changed from $hostname to the root of the zone after the IP updates (which is side-by-side with another A record of the same name that points somewhere else and IS proxied).
So e.g. if $hostname is set to “foo .bar .com”, even though the A record at $dnsRecordID is already set to “foo .bar .com”, this script changes it to “bar .com” (in addition to correctly setting the IP).
I get the same behavior if I set $hostname to just “foo” as well.
$body = ConvertTo-Json @{
‘type’ = ‘A’
‘name’ = $hostname
‘content’ = $myIP
‘ttl’ = 1
}
Write-Output “Attempting to update $hostname in zone ID $ZoneID and DNS Record ID $dnsRecordID with IP $myIP”
Invoke-RestMethod https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records/$dnsRecordID -Method Put -Authentication Bearer -Token $token -Body $body