I am developing an Python REST api and for server side I'm using Django with django-rest-framework. I managed to successfully test my api with AdvancedRestClient in chrome, but I can't get it working with python requests.
My ARC request looks like this:

And for my test Python request I wrote the following code:
import requests
import json
payload = {"TimeStamp": "2016-02-07T13:38:16Z", "DateInserted": "2016-02-07T13:38:18Z", "Value": 17.145, "Sensor": 1}
url = "http://127.0.0.1:8000/api/Readings"
headers = {"Content-Type": "application/json", "Authorization": "966271f8-94a3-4232-95f7-953f3b7989f3"}
r = requests.put(url, data=json.dumps(payload), headers=headers)
I tried many different things as using json= instead of data= but my request always seem to have no data content when they arrive to my server side. I searched the web but couldn't find any viable examples of using POST with requests so I'm hoping someone has some first-hand experience in their sleeve to share with me.
Update: The following code now works with django-rest-framework.
payload = {"TimeStamp": "2016-02-07T13:38:16Z", "DateInserted": "2016-02-07T13:38:18Z", "Value": 12.123, "Sensor": 1}
url = "http://127.0.0.1:8000/api/Readings/"
headers = {"Content-Type": "application/json", "Authorization": "966271f8-94a3-4232-95f7-953f3b7989f3"}
r = requests.put(url, data=json.dumps(payload), headers=headers)
http://httpbin.org/putto see what you are actually sending.print json.dumps(json.loads(r.text), indent=4)andprint r.status_codeto your snipplet and report the result. (Also add theTokenin theAuthorizationheader.)