I need to PUT data from a string (no dict) as the body of the call to a REST API.
When I call
r = requests.put(url, data = string)
then I can see in r.request.body
after this call that it is None
. Also, the server responds with a "411 Length Required" error.
However, when I try it with a dict instead of a string then it works, as the server responds with the correct JSON data. Moreover, in that case I can see in r.request.body
the correct data.
Any ideas?
PS: I am using Python 2.7.3 and Python-requests 1.2.0