Hello, I have been creating an app to auto update DNS IPs for use with dynamic IP addresses. I can use cURL to find both the Zone ID and the individual record IDs (represented by Z’s and R’s respectively), as well as using my global API key (the X’s) for certainty. The issue is when I send a request to change the record it responds with a JSON parsing error.
When I input this in my console (with the latest version of cURL): C:\Curl\bin>curl -X PATCH "https://api.cloudflare.com/client/v4/zones/zzzzzzzzzzzzzzzzzzzzzz/dns_records/rrrrrrrrrrrrrrrrrrr" -H "X-Auth-Email: [email protected]" -H "X-Auth-Key: xxxxxxxxxxxxxxxxxxxxxxxxx" -H "Content-Type: application/json" --data '{"type":"A","name":"example.com","content":"123.123.123.123","ttl":1,proxied":true}'
The response from Cloudflare API: {"result":null,"success":false,"errors":[{"code":9207,"message":"Failed to parse request body, content-type must be application/json"}],"messages":[]}
What am I doing wrong…this is almost cookie cutter from the example in the Cloudflare API docs (Cloudflare API v4 Documentation). Thank you in advance!
I must have copied it incorrectly, but it still responds with “Failed to parse request body, content-type must be application/json” (Even after fixing the quotes around proxied).
Investigate how Windows handles quotes on the command line. My guess is your quotes render the JSON invalid on it. You’ll probably need some string escaping.
Maybe run cURL in verbose mode so you see what it actually sends.
It seems Windows was doing something with the double quotes. I escaped them with backslashes and that fixed everything. Thank you so much Sandro for you time