How to use POST Request with Parameters in Python?

Published On: 12/09/2022 | Category: Python


Hi Guys,

In this short tutorial we will cover an python http post request json. you will learn python post request with query parameters. I explained simply about python post request example. This tutorial will give you simple example of python http request example.

Here, we will use requests library to all POST HTTP Request and get json response in python program. i will give you very simple example to call POST Request with body parameters in python.

So let's see bellow example:

Example main.py
import requests
  
# GET Request API URL
url = 'https://reqres.in/api/users'
  
# Adding Parameters
params = dict(
    name="Bhavesh",
    job="Web Developer",
)
  
response = requests.post(url, params)
  
# Getting Response in JSON
data = response.json()
  
print(data)
Output:
{
    'name': 'Bhavesh', 
    'job': 'Web Developer', 
    'id': '9', 
    'createdAt': '2022-09-12T04:36:33.545Z'
}

It will help you....

Happy Python Coding!