ItSolutionStuff.com

Python Post Request with pem File Example

By Hardik Savani • October 30, 2023
Python

Hey,

I am going to explain you example of python post request with pem file. We will look at example of python post request with certificate. I would like to share with you python http request with cert. I would like to share with you python requests post pem file.

Here, we will use requests library to all POST HTTP Request with pem file or certificate file and get JSON response in python program. In this example i will create pem file as client certificate and send http request with client certificate. 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:

Example:

main.py

import requests
import json
  
url = 'https://reqres.in/api/users'
  
headers = {
             'Accept' : 'application/json', 
             'Content-Type' : 'application/json'
             }
  
param = {
    "name": "Hardik", 
    "job": "Developer"
}
  
response = requests.post(url, json=param, headers=headers, verify='/path/cert.pem')
  
data = response.json()
  
print(data)

Mame sure, you have to put "/path/cert.pem" certificate file on path.

Output:

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Python Post Request with Basic Authentication Example

Read Now →

Python Post Request with Bearer Token Example

Read Now →

Python Create Zip Archive from Directory Example

Read Now →

Python List All Dates Between Two Dates Example

Read Now →

How to Check if Today is Sunday or not in Python?

Read Now →

How to Check if Today is Thursday or not in Python?

Read Now →

Python PATCH Request with Parameters Example

Read Now →

Python DELETE Request Example Tutorial

Read Now →

Python PUT Request with Parameters Example

Read Now →

Python POST Request with Parameters Example

Read Now →

Python GET Request with Parameters Example

Read Now →