Closed rethore closed 9 years ago
I have figured it out:
payload = {'firstname': 'lapin',
'lastname': 'lauvages4',
'location': {'address': 'blabla', 'city': 'Paris'}}
headers = {'Content-type': 'application/json; charset=utf-8'}
r = requests.post('http://127.0.0.1:5000/people', data=json.dumps(payload), headers=headers)
print r.text
print r.url
{"_updated": "Tue, 14 Apr 2015 08:35:52 GMT", "_links": {"self": {"href": "people/552cd168bd84780289f8a609", "title": "person"}}, "_created": "Tue, 14 Apr 2015 08:35:52 GMT", "_status": "OK", "_id": "552cd168bd84780289f8a609", "_etag": "e8c53dd08bc953757ef26af0d3c46e4eecc8e2a9"}
http://127.0.0.1:5000/people
:+1:
Hi, I'm trying to use your demo example with the requests library. It does work fine when sending just the
firstname
andlastname
. But not when sending thelocation
dictionary.But it work fine with curl. I guess I'm missing something in the request code, but I really can't figure it out.
Do you have any idea what I'm doing wrong? Thanks!