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:

Copy>>> 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?
The json= parameter takes a dictionary and automatically converts it to a JSON string. The Request Library automatically adds the Content-Type: application/json header to your request when using the json= parameter. In this Python Requests POST JSON example, we send a JSON data string to the ...
🌐
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 simplest way to post JSON data ... is by using the json parameter in the post method. This method automatically serializes your Python dictionary into a JSON string, making it effortless to send data to the server. ... import requests url = "https://api.example.com/data" data = { "name": "John Doe", "email": "john.doe@example.com" } response = requests.post(url, ...
Discussions

How can I POST JSON data with Python's Requests library? - Stack Overflow
I need to POST JSON content from a client to a server. I'm using Python 2.7.1 and simplejson. The client is using Requests. The server is CherryPy. I can GET hard-coded JSON content from the server... More on stackoverflow.com
🌐 stackoverflow.com
I don't really understand Requests python module
You might want to start with some basics on client-server communication before delving into networking/web-dev side of Python. As others have mentioned here, requests docs is a great place to learn about the library, but if you don't know what a 'POST' or 'GET' method is or what's a request header used for, the docs won't make much sense. There are plenty of free online resources which explains the above concepts. Listing some of them which I think should cover your case: https://www.freecodecamp.org/news/http-request-methods-explained/ https://doc.oroinc.com/api/http-methods/ https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON More on reddit.com
🌐 r/learnpython
45
100
July 24, 2022
[Python] How to parse JSon response from a post request (Requests)
If I run your code I get NameError on session, maybe you need to define that for it to work? More on reddit.com
🌐 r/learnprogramming
9
2
March 2, 2017
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
🌐
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 article, we took a look at how to use the requests library to make a POST request with JSON data in Python.
🌐
Carmatec
carmatec.com › home › python requests post json: best practices & examples 2026
Python Requests POST JSON: Best Practices & Examples 2026
February 3, 2026 - python from requests.auth import HTTPBasicAuth r = requests.post(url, json=payload, auth=HTTPBasicAuth("user", "pass")) # or shorthand r = requests.post(url, json=payload, auth=("user", "pass")) python def get_access_token(): r = requests.post( "https://auth.example.com/token", data={"grant_type": "client_credentials", "client_id": "...", "client_secret": "..."} ) return r.json()["access_token"] token = get_access_token() r = requests.post(api_url, json=data, headers={"Authorization": f"Bearer {token}"})
🌐
W3Schools
w3schools.com › python › ref_requests_post.asp
Python Requests post Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... import requests url = 'https://www.w3schools.com/python/demopage.php' myobj = {'somekey': 'somevalue'} x = requests.post(url, json = myobj) print(x.text) Run Example »
🌐
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.
Find elsewhere
🌐
W3docs
w3docs.com › python
How to POST JSON data with Python Requests?
Here is a code snippet that ... headers = {'Content-type': 'application/json'} response = requests.post('https://httpbin.org/post', data=json_data, headers=headers) # Print the response print(response.text) ...
🌐
Apify
blog.apify.com › python-post-request
How to post JSON data with Python Requests
December 7, 2025 - The Python Requests library is widely used for making HTTP requests. Here are some tips for making effective POST requests: Sending JSON data: The best way to send JSON data is to use the json parameter of the requests.post() function.
🌐
GitHub
gist.github.com › thepacketgeek › 6691361
POST JSON from Python with Requests · GitHub
POST JSON from Python with Requests · Raw · python-post-json.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
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.
🌐
Codegive
codegive.com › blog › requests_python_json_post.php
Mastering <code>requests</code> Python JSON POST (2026): Unleash Your API Communication Power Today!
March 24, 2026 - Example 5: Robust Error Handling for POST Requests5. Common Mistakes When Using requests python json post
🌐
Scrapfly
scrapfly.io › blog › posts › how-to-python-requests-post
Guide to Python requests POST method
April 18, 2026 - Discover how to use Python's requests library for POST requests, including JSON, form data, and file uploads, along with response handling tips.
🌐
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 - Python handles this beautifully with dictionaries and lists. import requests url = "https://httpbin.org/post" nested_data = { "user": { "name": "Alice", "contact": { "email": "alice@example.com", "phone": "123-456-7890" } }, "roles": ["admin", "editor"] } response = requests.post(url, json=nested_data) print(response.json()) # Echoed response
🌐
LoadForge
loadforge.com › directory › getting-started › json-posts
POSTing JSON data - Getting Started - LoadForge - LoadForge
Setup and Imports Start by importing necessary modules like time, json, and relevant locust classes. Define User Behavior Create a class (QuickstartUser) that extends the HttpUser class from Locust. This will define the behavior of a simulated user. Set Waiting Time Use wait_time to simulate the wait period between tasks. This example uses a randomized wait time of 3 to 5 seconds. Define the Task Within the user class, define a task named api_page. This task sends a POST request with the payload.
🌐
ProxiesAPI
proxiesapi.com › articles › sending-and-receiving-json-data-with-python-requests
Sending and Receiving JSON Data with Python Requests | ProxiesAPI
Requests will serialize the dict to JSON and add the correct Content-Type header for you: ... import requests data = { 'name': 'John Doe', 'age': 30 } response = requests.post('https://api.example.com/users', json=data)
🌐
Datasciencebyexample
datasciencebyexample.com › 2023 › 03 › 12 › using-json-or-data-parameter-in-requests-post
Difference between `json` and `data` parameter of the HTTP POST Requests with JSON Data in Python using the Requests Library | DataScienceTribe
March 12, 2023 - In this example, we define a url variable that represents the endpoint where we want to send the POST request. We also define a payload variable that contains the JSON data we want to send. To send the POST request, we use the requests.post() method and pass the url and json parameters.
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_post_json_data_with_python_requests
How to POST JSON data with Python Requests?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-requests-post-request-with-headers-and-body
Python requests - POST request with headers and body - GeeksforGeeks
July 23, 2025 - import requests url = "https://httpbin.org/post" data = { "id": 1001, "name": "geek", "passion": "coding", } response = requests.post(url, json=data) print("Status Code", response.status_code) print("JSON Response ", response.json()) Output: ...
🌐
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....