Requests is an HTTP client library for the Python programming language. Requests is one of the most downloaded Python libraries, with over 300 million monthly downloads. It maps the HTTP protocol onto Python’s object-oriented semantics.
requests.post(url, data=data) – function sends a POST request to the specified URL with the provided data. The data dictionary contains the key-value pairs that we want to send in the POST request payload. You can modify it based on the requirements of the API we are working with.
The response object contains information about the response, including the status code and the response content.
The output of the above program is
In the above example, we have passed the request body in the requests.post(). In the below example, will define a variable and assign the request body to it.