Cant update dns record, error "PUT method not allowed for the api_token authentication scheme"

I cannot change the dns entry, I use a Manage access and permissions token.

my code

headers = {
    "X-Auth-Email": auth_email,
    "Authorization": "Bearer " + auth_key,
    "Content-Type": "application/json"
}

data = {
    "type": "",
    "name": domain,
    "content": "",
    "ttl": 1,
    "proxied": True
}


def setIp_v4(ip):
    data["type"] = "A"
    data["content"] = ip

    r = requests.put(
        url=update_url,
        headers=headers,
        data=data,
        timeout=15
    )

    print(r.content)

returns
b'{"success":false,"errors":[{"code":10000,"message":"PUT method not allowed for the api_token authentication scheme"}]}\n'

how can i change the ip with a limited token?

oh, this is the domain

update_url = f"https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records/{record_id}"

You are combined both API schemes, which causes weird results. If you are using an API token (not the global key) then try removing the X-Auth-Email header and see if that fixes it.

dosnt work :confused:

headers = {
    "Authorization": f"Bearer {auth_key}",
    "Content-Type": "application/json"
}

ok found the error, the var. “record_id” was assigned before setting, so the url was set without the record id.