Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3647

Python requests: How to PUT a string in body?

$
0
0

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


Viewing all articles
Browse latest Browse all 3647

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>