PUT method Python requests (original) (raw)

Last Updated : 12 Jul, 2025

The requests library is a powerful and user-friendly tool in Python for making HTTP requests. The PUT method is one of the key HTTP request methods used to update or create a resource at a specific URI.

Working of HTTP PUT Method

Syntax

requests.put(url, params={key: value}, **args)

**Parameters:

Installation

To use the requests module, we need to first install it using this command:

pip install requests

Example – Making a PUT Request

In this example, we are going to make a real PUT Request using httpbin.org, a public testing **API.

Python `

import requests

res = requests.put('https://httpbin.org/put', data={'key': 'value'})

print("Status Code:", res.status_code)

print("Response Body:", res.content.decode())

`

**Output:

put-request

Terminal Output

**Explanation: