'How to correctly send payload using requests?

I'm trying to send post request using python requests module and I'm getting this error as a result:

b'ParseError at [row,col]:[0,23]\nMessage: Expected a \',\' or \'}\' at character 23 of {"subjectFilters":eori=&idSisc=&fullName=&nip=&shortName=global+trade&page=0&limit=10}. '
400

My code:

 with requests.Session() as s:
        r = s.post(data['dataURL'], data=data['dataPayload'], headers=data['dataHeaders'])
        print(r.content)
        print(r.status_code)

data.json file:

{"dataURL": "my_url",
    "dataPayload": {
        "eori": "",
        "fullName": "",
        "idSisc": "",
        "limit": "10",
        "nip": "",
        "page": "0",
        "shortName": "global trade"
    },
    "dataHeaders": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36",
        "Content-type": "application/json",
        "Accept": "application/json, text/plain, */*"
    }}

That's how payload looks like from chrome dev tools

1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source