Content must be json

import requests

CLOUDFLARE_ENDPOINT_URL = "https://api.cloudflare.com/client/v4/zones/MyZoneID/dns_records/MyDnsIdentifier"

headers = {

    "Authorization": "Bearer MyToken",

    "Content-type" : "application/json"

}

data = {

    "type": "A",

    "name": "mc.example.com",

    "content": "77x.xxx.xxx.xxx",

    "ttl": "1",

    "proxied": "true"

}

r = requests.put(CLOUDFLARE_ENDPOINT_URL, headers=headers, data=data)

print(r.text)

What am I doing wrong?
I’m getting this error: {"result":null,"success":false,"errors":[{"code":9207,"message":"Content-type must be application/json."}],"messages":[]}
its literally json

Could you try json=data instead of data=data? Then requests should serialize the dictionary for you :slightly_smiling_face:

Also, I believe the "ttl" and "proxied" attributes should be an integer and boolean respectively, not a string.