Reputation: 1
I'm using Python 2.7's json.dumps
to post data to a website:
v = json.dump({'addresses.address': '123 Main St', 'addresses.city': 'Somewhere'})
If I print out the data, it looks fine:
{'addresses.address': '123 Main St', 'addresses.city': 'Somewhere'}
but once its posted via
requests.post(url, headers=headers, data=v, verify=False)
it add extra info to the request:
{"{'addresses.address': '123 Main St', 'addresses.city': 'Somewhere'}"=>nil}
Upvotes: 0
Views: 1670
Reputation: 122376
You can pass the dictionary directly to json
:
v = {'addresses.address': '123 Main St', 'addresses.city': 'Somewhere'}
requests.post(url, headers=headers, json=v, verify=False)
This is possible as of requests 2.4.3.
Upvotes: 1