python-requests Getting started with python-requests POST requests


POST requests are made with the 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 ='', 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 ='', data={"a": 1, "b": 2})