python requests POST 400 error
The easiest technique is to use json
instead of data
as followed:
requests.post(url, headers=headers, params=params, json=data)
Based on the comments, your server is actually expecting data as a stringified JSON object. As far as the params are concerned, it'd most probably help if they're declared as a tuple of tuples (or a dict of dicts)
Try the following -
headers = {
'content-type': 'application/json',
}
params = (
('priority', 'normal'),
)
data = {
"atribute_a": "value",
"atribute_b": false
}
requests.post(url, headers=headers, params=params, data=str(data))