Python Post Request with Json File Example

By Hardik Savani October 30, 2023 Category : Python


This post is focused on python post request with json file. This tutorial will give you simple example of python request with json body. This article goes in detailed on python post request with json file. it's simple example of python request json file.

Here, we will use requests library to all POST HTTP Request with json file as parameters and get JSON response in python program. In this example i will create parameters.json file and take json parameters from that file. I will give you a very simple example to call POST Request with body parameters in python.

You can use these examples with python3 (Python 3) version.

let's see below simple example with output:


import requests
import json
url = ''
headers = {
             'Accept' : 'application/json', 
             'Content-Type' : 'application/json'
contents = open('parameters.json', 'rb').read()
response =, data=contents, headers=headers)
data = response.json()


    "name": "Hardik", 
    "job": "Developer"


I hope it can help you...

Tags :