Why My Python requests.post() is Sending a GET Instead of POST

Feb 3, 2024 ยท 2 min read

When working with Python's popular requests library for making HTTP requests, you may occasionally run into an issue where calling requests.post() seems to send a GET request instead of the expected POST.

This can be frustrating, but there are a few common reasons why this happens:

Forgetting to Pass Data

One main reason requests.post() may send a GET instead is if you forget to pass in the data or json argument. For example:

import requests

url = 'https://api.example.com/create_resource'

This will send a GET request since no request body data was specified. To fix, pass a data or json argument:

data = {'name': 'John Doe'}
requests.post(url, data=data) 

Request is Redirected

Another possibility is the initial POST request you make is redirected by the server to a GET request unbeknownst to you. You can check the final request method in the response history:


If it shows GET that means it was redirected.


In summary, requests.post() sending a GET instead of POST usually boils down to either:

  • Forgetting to pass data/json in the request
  • The server redirecting the POST to a GET
  • Checking the request history and response codes can help debug odd request behavior like this when using requests.

    Browse by tags:

    Browse by language:

    The easiest way to do Web Scraping

    Get HTML from any page with a simple API call. We handle proxy rotation, browser identities, automatic retries, CAPTCHAs, JavaScript rendering, etc automatically for you

    Try ProxiesAPI for free

    curl "http://api.proxiesapi.com/?key=API_KEY&url=https://example.com"

    <!doctype html>
        <title>Example Domain</title>
        <meta charset="utf-8" />
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />


    Don't leave just yet!

    Enter your email below to claim your free API key: