python – Discord API authorization returns 401 with correct Token

I’m tring to learn direct API calls on Discord.

url = ""

    json = {
        "name": "blep",
        "type": 1,
        "description": "Send a random adorable animal photo",
        "options": (
                "name": "animal",
                "description": "The type of animal",
                "type": 3,
                "required": True,
                "choices": (
                        "name": "Dog",
                        "value": "animal_dog"
                        "name": "Cat",
                        "value": "animal_cat"

    # For authorization, you can use either your bot token
    headers = {
        "Authorization": "Bot <TOKEN>"
    r =, headers=headers, json=json)

Pretty much what is in Discord’s docs about slash commands, though It keeps returning 401
I’m sure the token is good, as I’m maintaining regular bot process with it in the same script, and I have no idea what other problem can it be…