bad request error 400 while using python requests.post function

Posted by Toussah on Stack Overflow See other posts from Stack Overflow or by Toussah
Published on 2013-11-08T15:50:19Z Indexed on 2013/11/08 15:53 UTC
Read the original article Hit count: 410

I'm trying to make a simple post request via the requests library of Python and I get a bad request error (400) while my url is supposedly correct since I can use it to perform a get. I'm very new in REST requests, I read many tutorials and documentation but I guess there are still things I don't get so my error could be basic. Maybe a lack of understanding on the type of url I'm supposed to send via POST. Here my code :

import requests
v_username = "username"
v_password = "password"
v_headers = {'content-type':'application/rdf+xml'}
url = 'https://my.url'
params = {'param': 'val_param'}
payload = {'data': 'my_data'}
r = requests.post(url, params = params, auth=(v_username, v_password), data=payload, headers=v_headers, verify=False)
print r

I used the example of the requests documentation.

© Stack Overflow or respective owner

Related posts about python

Related posts about python-2.7