Created
September 4, 2017 07:39
-
-
Save VITIMan/f3400cbc5fa053d18e8a785e47f879b0 to your computer and use it in GitHub Desktop.
Requests library snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# from https://stackoverflow.com/a/35534695 | |
payload = [{"json": "array"}, {"another": "element"}] | |
headers = {'Content-Type': 'application/json', 'Accept':'application/json'} | |
requests.post(url,data=json.dumps(payload), headers=headers) | |
# In newer versions of requests | |
# from https://stackoverflow.com/a/35535240 | |
requests.post(url, json=payload, headers=headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment