DNS API Returns JSON Parse Error

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 (https://api.cloudflare.com/#dns-records-for-a-zone-patch-dns-record). Thank you in advance!

Seems you are missing a double quote in your JSON.

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).

Did you verify the JSON is correct now? Double check that.

The JSON looks correct to me… please take a look:

You really need to verify this manually. Use one of the JSON validators out there.

Just ran your request and it ran fine. The issue is most likely still with your JSON.

I checked it on jsonlint.com, and it formated it correctly and said it was valid json. Could it possibly be anything else?
asdfasdf

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 :slight_smile:

Happy it works :slight_smile: