Voting giving error

I am trying to use the API in python for voting and I am getting a really weird error.

The weird error message is at the bottom of the post - it has a backslash in the URL part of the error message which makes me think it might not be working correctly.

I am doing a post to the voting URL, I am passing my key in the header, and I am passing a json file of the parameters to the body of the POST.

I have tried every idea I could come up with and none of them are working, any help would be great!

This is my python function:

import json

import requests

#vote cat image in API
def VoteCatImage(imageID, voteValue):
    # API search url
    url = ''

    #if downvoting
    if voteValue == 0:
        body = {
            'image_id': imageID,
            "value": "0",
    #if upvoting
    if voteValue == 1:
        body = {
            "image_id": imageID,
            "value": "0",


    # request an image from API
    r =, headers=headers, data=json.dumps(body))    


These are my console messages
    imageID - ae8
    voteNumber -  0
    url -
    headers - {'X-API-KEY': '703e54c8-b93b-4121-a147-4eff743f99cf'}
    body - {"image_id": "ae8", "value": "0"}
    response text - {"message":"\"image_id\" is required","status":400,"level":"info"}

This was the solution!

r =, headers=headers, json=body)

json.dumps() converts the dictionary to a json so I’m not sure what the problem was exactly.

json=body converts the dictionary to a json as well.

Well done @AlexM - let me know if you have any other issues.

Best, Aden