💡
Python requests
pip install requests
import json
url = 'https://api.github.com/some/endpoint'
payload = {'some': 'data'}
headers = {'content-type': 'application/json'}
r = requests.post(url, data=json.dumps(payload), headers=headers)
url = 'http://httpbin.org/post'
files = {'file': ('report.xls', open('report.xls', 'rb'))}
r = requests.post(url, files=files)
r.text
{
...
"files": {
"file": "<censored...binary...data>"
},
...
}
Discussion