Im trying to post data to my Django server but when I check the server the Querydict is empty. When I call from the browser it does look good.
import requests
import json
headers = {
"AUTHORIZATION": "1234",
"Content-type": "application/json",
"Accept": "text/plain"
}
print headers
payload = {
"start_date_s":"04/01/2016",
"start_date_e":"04/15/2016"
}
r = requests.post('http://localhost:8000/get-ticket-data',headers=headers, json = json.dumps(payload))
print r.content
print r.text
答案 0 :(得分:0)
如果使用json
参数,则应按原样传递dict,不要转储它(docs):
r = requests.post('http://localhost:8000/get-ticket-data',headers=headers, json=payload)
答案 1 :(得分:0)
如果你发送json请求,你需要在django视图中使用request.POST
来获取它,而不是AES_encrypt