Starting with Requests version 2.4.2, you can use the json= parameter (which takes a dictionary) instead of data= (which takes a string) in the call:

>>> import requests
>>> r = requests.post('http://httpbin.org/post', json={"key": "value"})
>>> r.status_code
200
>>> r.json()
{'args': {},
 'data': '{"key": "value"}',
 'files': {},
 'form': {},
 'headers': {'Accept': '*/*',
             'Accept-Encoding': 'gzip, deflate',
             'Connection': 'close',
             'Content-Length': '16',
             'Content-Type': 'application/json',
             'Host': 'httpbin.org',
             'User-Agent': 'python-requests/2.4.3 CPython/3.4.0',
             'X-Request-Id': 'xx-xx-xx'},
 'json': {'key': 'value'},
 'origin': 'x.x.x.x',
 'url': 'http://httpbin.org/post'}
Answer from Zeyang Lin on Stack Overflow
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ python โ€บ m2g4va4a โ€บ python-requests-post-json-example
How do I post JSON using the Python Requests Library?
For many programming languages, ... the .json file extension. ... HTTP POST method requests the webserver to accept the data enclosed in the POST request message body to process or store it....
๐ŸŒ
Apidog
apidog.com โ€บ blog โ€บ python-requests-post-json
Python Requests: How to POST JSON Data with Ease in 2026
February 4, 2026 - Step 2: Click on the Request tab and select POST from the dropdown menu. Step 3: Enter the URL of the API endpoint you want to test, in the Headers section, add any required headers.
Discussions

How can I POST JSON data with Python's Requests library? - Stack Overflow
Good catch - I saw your application/json in GET and somehow missed that you hadn't provided it on the request. You may also need to make sure that you return something from POST or you might get a 500. 2012-03-31T04:01:45.18Z+00:00 ... Doesn't seem to be necessary. When I print r, I get More on stackoverflow.com
๐ŸŒ stackoverflow.com
Why is the json information not loading in from the request ?
How would i simulate the download action with requests. The url I have is suppose to be the end point. If I inspect the response.text what exactly am I looking for to see how the html takes json data? ... Python Requests, response.json() returning string object instead of dict. More on reddit.com
๐ŸŒ r/learnpython
9
2
January 19, 2024
APIs: Params= vs json= whats the difference?
Maybe it's a good idea to study the basics of HTTP methods: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods A GET request has no body, so the only (practical) way of delivering data with it is through its url, so GET hostname/api/some_object/?name='test' The requestst library supports that via its params= parameter. So in this case you would do params={'name': 'test'}. Then methods like PUT and POST are meant to deliver data through their body, for which you would normally use the data= parameter. However to simplify delivering a Python structure (dict/list or some combination thereof) as a JSON encoded body, it supports that via its json= parameter. It then also sets the correct content-type header. More on reddit.com
๐ŸŒ r/learnpython
4
2
November 26, 2021
PSA: Latest Tautulli update crashes on startup with simplejson errors -- easy fix though
Took me a bit to track down This was my first chance to test Claude Code and Claude had this error pinpointed and guidance provided in 30 seconds. Impressive. More on reddit.com
๐ŸŒ r/Tautulli
13
20
April 3, 2026
People also ask

What is the difference between data and json parameters in Python requests?

data is for form-encoded (default) or raw data (when Content-Type header is overriden). While json is specifically for JSON format data and automatically sets Content-Type to application/json.

๐ŸŒ
scrapfly.io
scrapfly.io โ€บ blog โ€บ posts โ€บ how-to-python-requests-post
Guide to Python requests POST method
Does the Python requests library support asynchronous POST requests?

Unfortunately, the requests library does not support asynchronous requests. However, the httpx library is an alternative that provides async capabilities, making it suitable for applications requiring concurrency. See our guide to Python httpx for details.

๐ŸŒ
scrapfly.io
scrapfly.io โ€บ blog โ€บ posts โ€บ how-to-python-requests-post
Guide to Python requests POST method
How can I include custom headers in using Python requests?

Pass headers as a dictionary using the headers parameter. Note that requests automatically generates some headers like User-Agent, Content-Length and Content-Type, so be cautious when overriding them.

๐ŸŒ
scrapfly.io
scrapfly.io โ€บ blog โ€บ posts โ€บ how-to-python-requests-post
Guide to Python requests POST method
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_requests_post.asp
Python Requests post Method
Make a POST request to a web page, ... requests.post(url, json = myobj) print(x.text) Run Example ยป ยท The post() method sends a POST request to the specified url....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ response-json-python-requests
response.json() - Python requests - GeeksforGeeks
July 12, 2025 - To print the JSON data fetched we have used json() method which prints the JSON data in the Python dictionary format as seen in the output. In this way, we can pas parse JSON responses in Python. ... # import requests module import requests # Making a get request response = requests.get('https://api.github.com///') # print response print(response) # print json content print(response.json())
๐ŸŒ
Apify
blog.apify.com โ€บ python-post-request
How to post JSON data with Python Requests
December 7, 2025 - Accessing content: Access the response content using the text or json methods of the Response object. Error handling: Wrap your POST request code in a try-except block to handle potential errors.
Find elsewhere
๐ŸŒ
Scrapfly
scrapfly.io โ€บ blog โ€บ posts โ€บ how-to-python-requests-post
Guide to Python requests POST method
April 18, 2026 - application/json represents JSON format commonly used in API communication. application/x-www-form-urlencoded used in HTML form submissions, encoding data as URL-encoded key-value pairs. multipart/form-data designed for file uploads, supporting mixed content like binary files and text in a single request. To set the Content-Type header in python requests use the headers parameter: ... import requests response = requests.post( 'https://httpbin.dev/post', headers={ "Content-Type": "application/json", }, data='{ "key": "value" }' )
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ post json data with requests python
How to POST JSON Data With requests in Python | Delft Stack
March 4, 2025 - The requests.post method is called, with the URL and the data passed in as a JSON object. The response from the server is printed, showing both the status code and the JSON response.
๐ŸŒ
Requests
requests.readthedocs.io โ€บ en โ€บ latest โ€บ user โ€บ quickstart
Quickstart โ€” Requests 2.34.2 documentation
1 month ago - Some servers may return a JSON ... 500). Such JSON will be decoded and returned. To check that a request is successful, use r.raise_for_status() or check r.status_code is what you expect. In the rare case that youโ€™d like to get the raw socket response from the server, ...
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ how-to-post-json-data-using-requests-library-in-python
How to POST JSON Data Using requests Library in Python
June 27, 2023 - In this section, we'll cover how to handle common errors you may face when making POST requests we've been discussing so far. Let's start with a simple example that demonstrates how to check for errors in the response: import requests url = 'https://jsonplaceholder.typicode.com/posts' headers = {'Content-type': 'application/json'} data = '{"title": "foo", "body": "bar", "userId": 1}' response = requests.post(url, headers=headers, data=data) if response.status_code != requests.codes.ok: raise Exception('Request failed with status code:', response.status_code)
๐ŸŒ
Carmatec
carmatec.com โ€บ home โ€บ python requests post json: best practices & examples 2026
Python Requests POST JSON: Best Practices & Examples 2026
February 3, 2026 - JSON is the default for programmatic APIs. python import requests payload = { "user_id": 1001, "action": "purchase", "items": [ {"product": "Wireless Mouse", "qty": 2, "price": 29.99} ], "timestamp": "2026-02-03T12:07:00+05:30" } response = requests.post( "https://api.example.com/events", json=payload, # โ† magic line timeout=12 ) print(response.status_code) # e.g.
๐ŸŒ
W3docs
w3docs.com โ€บ python
How to POST JSON data with Python Requests?
You can use the requests library in Python to send a POST request with JSON data. Here is a code snippet that demonstrates how to do it: import json import requests # Prepare the JSON data data = {'name': 'John', 'age': 30} json_data = ...
๐ŸŒ
Plain English
python.plainenglish.io โ€บ how-to-send-post-requests-with-json-data-using-python-requests-daaffa0a3335
How to Send POST Requests with JSON Data Using Python Requests? | Python in Plain English
April 25, 2025 - import requests # Your API endpoint url = "https://httpbin.org/post" # Your data as a Python dictionary data = { "name": "Alice", "email": "alice@example.com", "age": 28 } # Send POST request with JSON data response = requests.post(url, json=data) # ...
๐ŸŒ
Techgrind
techgrind.io โ€บ home โ€บ explain โ€บ how to post json data with python requests?
How to POST JSON data with Python Requests? | Techgrind.io
January 3, 2025 - if response.status_code == 200: # Successful request result = response.json() # Convert JSON response to a Python dict print("User created successfully:", result) else: print(f"Request failed with status code {response.status_code}") print("Error message:", response.text) Authentication and Headers If your API requires authentication, you can add tokens or custom headers: headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Custom-Header": "CustomValue" } response = requests.post("https://api.example.com/users", json=data, headers=headers)
๐ŸŒ
Python Pool
pythonpool.com โ€บ home โ€บ blog โ€บ python requests json: a comprehensive guide
Python Requests JSON: A Comprehensive Guide - Python Pool
February 25, 2023 - We set the headers to include a Content-Type of application/json, indicating that we are sending JSON data in the request body. After that define the JSON data to be sent in the request body as a Python dictionary.
๐ŸŒ
ProxiesAPI
proxiesapi.com โ€บ articles โ€บ sending-and-receiving-json-data-with-python-requests
Sending and Receiving JSON Data with Python Requests | ProxiesAPI
import requests data = { 'name': 'John Doe', 'age': 30 } response = requests.post('https://api.example.com/users', json=data) No need to encode to JSON yourself! This makes working with web APIs that accept JSON very straightforward. Many modern web APIs return JSON formatted responses. Requests will automatically decode the JSON response so you can access it as a Python dict or list:
๐ŸŒ
Real Python
realpython.com โ€บ python-requests
Python's Requests Library (Guide) โ€“ Real Python
July 23, 2025 - When you pass JSON data via json, Requests will serialize your data and add the correct Content-Type header for you. As you learned earlier, the httpbin service accepts test requests and responds with data about the requests.
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ json โ€บ python post json using requests library
Python Post JSON using requests library
May 14, 2021 - Select POST request and enter your service POST operation URL. Click on Headers. In the key column enter Content-Type and in the Value column enter application/json. Click on the body section and click the raw radio button. enter your JSON data.
๐ŸŒ
DEV Community
dev.to โ€บ apilover โ€บ python-requests-mastering-json-data-post-leh
Python Requests: Mastering JSON Data POST - DEV Community
February 12, 2025 - POST is ideal for creating resources (e.g., submitting a form, uploading a file). import requests url = "https://api.example.com/users" payload = {"name": "Ashley", "role": "Developer"} _# Automatically sets Content-Type to application/json _ response = requests.post(url, json=payload) print(f"Status: {response.status_code}") print(f"Response: {response.json()}")
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-requests-post-request-with-headers-and-body
Python requests - POST request with headers and body - GeeksforGeeks
July 23, 2025 - requests.post(url, data={key: value}, json={key: value}, headers={key:value}, args) *(data, json, headers parameters are optional.) Given below are few implementations to help understand the concept better.