Home >>Python Requests Module >Python Requests post() Method

Python Requests post() Method

Python Requests post() Method

Python Requests post() Method in python is used to sends a POST request to the specified url and when you want to send some data to the server.

Syntax:
requests.post(url, data={key: value}, json={key: value}, args)

Parameter Values

Parameter Description
url It is Required. The request of the url
params It is Optional. A dictionary, to send as a query string. Default value is None
allow_redirects It is Optional. To redirection of a Boolean(Default value is True)
auth It is Optional. to enable a certain HTTP authentication of a tuple. Default value is None
cert It is Optional. It specifying a cert file or key of a string or a tuple. Default value is None
cookies It is Optional. To send to the specified url of a directionary of cookies. Default value is None
headers It is Optional. to send to the specified url of a dictionary of HTTP headers. Default value is None
proxies It is Optional. The proxy url of the protocol. Default value is None
stream It is Optional and indicates a Boolean. Default False
timeout It is Optional. A tuple or a number, indicating how many seconds to wait for the client to make a connection
verify It is Optional. A string or a Boolean indication to verify the servers TLS certificate or not. Default value is True
Here is an example of Python Requests post() Method:

import requests
url = 'https://www.phptpoint.com/python/demopage.php'
myobj = {'somekey': 'somevalue'}
z = requests.post(url, data = myobj)
print(z.text)

Output:
<html>
<body>

<h1>This is Phptpoint </h1>

</body>
</html>