python-requests Getting started with python-requests POST requests


Example

POST requests are made with the request.post() method.

If you need to send a web form request as a POST body, pass in a dictionary with key-value pairs as the data argument; requests will encode these to a application/x-www-form-urlencoded mimetype body:

r = requests.post('https://github.com/', data={"a": 1, "b": 2})

If you need to POST a json payload, you can use json=. This will automatically set the Content-Type header to application/json

r = requests.post('https://github.com/', data={"a": 1, "b": 2})