How to handle HTTP Query Parameters in Python

HOME

https://reqres.in/api/users?page=2

import requests

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


def test_verify_header():
    params = {
        'pages': 2
    }

    response = requests.get(ENDPOINT, params)
    print(response.json())

    print("Response Header", response.headers)

    #Assert status code
    assert response.status_code == 200

    # Assert Response Body
    response_body = response.json()
    assert response_body["per_page"] == 6

    assert response_body["data"][0]["id"] == 1

pytest QueryParam_test.py

Leave a comment