Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post request error: Missing or Invalid Post Body

I'm getting the following error and I'm not sure why:

{"success":false,"errors":["Missing or invalid POST body."],"results":[]}

I'm not sure if there is a problem with how I have my code structured, sending bad json, or what. If you could give me an idea of where to troubleshoot this, that would be great. Thanks. Here is how I have my settings:

headers = {
    "Accept": "application/json",
    "Authorization": "bearer " + bearer_token,
    "Content-Type": "application/json",
}


data = {
        'limit':10,
        'sort':"MinPrice DESC",
        'filters':[
            {
                'name':'SetName',
                'values':'All'
            }
        ]
    }

url = 'http://api.tcgplayer.com/V1.9.0/catalog/categories/3/search'

def catalog_data():
    r = requests.post(url, headers=headers, data=data)
    print(r.text)

catalog_data()
like image 830
juju Avatar asked Jun 21 '26 17:06

juju


1 Answers

Making the change from data=data to json=data allowed my Post data to be read properly.

like image 169
juju Avatar answered Jun 23 '26 17:06

juju



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!