python - Requests POST data not being appended to url -
i trying send simple post request server using requests. doing (i think @ least) quickstart (http://docs.python-requests.org/en/master/user/quickstart/) saying do. post request seems ignoring data= tag , not appending data end of url. have:
import requests, json url = 'http://localhost:5000/todo/api/v1.0/tasks' payload = (('key1', 'value1'), ('key1', 'value2')) r=requests.post(url, data=payload) print 'url is: ', r.url
and output is:
url is: http://localhost:5000/todo/api/v1.0/tasks
i don't know if relevant or not, if use tag params=, url assembled expect:
r=requests.post(url, params=payload) url is: http://localhost:5000/todo/api/v1.0/tasks/?key1=value&key1=value2
anyone see wrong? in advance
try dump payload
json
, use dict
payload = {} payload[key1] = value1 payload[key2] = value2 payload_data = json.dumps(payload) r=requests.post(url, data=payload_data)
Comments
Post a Comment