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:

    Tired of getting blocked while scraping the web?

    ProxiesAPI handles headless browsers and rotates proxies for you.
    Get access to 1,000 free API credits, no credit card required!