How to test PUT Request Using Python Requests

HOME

pip install -U requests

pip install -U pytest

import requests

ENDPOINT = 'https://reqres.in/api/users/2'


def test_update_user():
    request_body = {
        "name": "Vibha",
        "Job": "CTO"
    }

    response = requests.put(ENDPOINT, request_body)
    response_body = response.json()
    print(response_body)
    assert response.status_code == 200
    assert response_body["Job"] == "CTO"

Requests in Python

HOME