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 › req › 4rwevrqh › post-json-example
How do I post JSON to the server?
January 16, 2023 - To post JSON data to the server, you need to provide the JSON data in the HTTP POST request body and pass the "Content-Type: application/json" request header. The Content-Type request header specifies the media type for the resource in the body.
🌐
JSON Editor Online
jsoneditoronline.org › home › data-fetching › post-json
How to POST JSON data in JavaScript | Indepth | JSON Editor Online
February 8, 2023 - This article explains what HTTP requests are and how to POST JSON data in JavaScript. Learn about common pitfalls and handy tools to fetch JSON data.
🌐
DEV Community
dev.to › ldakanno › making-a-post-request-using-json-server-h7c
Making a POST request using json-server - DEV Community
December 11, 2022 - To make any request other than GET, you will have to specify the method in which you are trying to use, in this example it would be POST since we are making a POST request. The header will communicate what kind of data we will be sending. The JSON.stringify method is really neat.
🌐
Baeldung
baeldung.com › home › http client-side › making a json post request with httpurlconnection
Making a JSON POST Request With HttpURLConnection | Baeldung
May 11, 2024 - To send a POST request, we’ll have to set the request method property to POST: ... Set the “content-type” request header to “application/json” to send the request content in JSON form.
🌐
ReqBin
reqbin.com › req › v0crmky0 › rest-api-post-example
How do I post JSON to a REST API endpoint?
To post JSON to a REST API endpoint, you must send an HTTP POST request to the REST API server and provide JSON data in the body of the POST message. You must also specify the data type using the Content-Type: application/json request header.
🌐
Atlassian
developer.atlassian.com › server › crowd › json-requests-and-responses
JSON requests and responses
Instead of XML you may provide and accept entities as JSON, a simpler and more concise format. Compare an authentication context, to be POSTed to the '/session' resource, as application/xml:
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1180617 › send-a-request-to-a-restapi-with-json
Send a request to a restapi with json - Microsoft Q&A
In addition to fields specific to the different types of requests, the standard fields HOST, CONTENT-LENGTH and CONTENT-TYPE must be present. The value of the CONTENT-TYPE header field must be “app/json”. Also, the HTTP verb used for requests should always be "POST".
Find elsewhere
🌐
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 - The json parameter automatically sets the Content-type header to application/json and encodes the data as JSON in the request body. Note: Both methods work equally well, so choose the one that fits your use case best. And that's pretty much it for making a POST request with JSON data using the requests library in Python.
🌐
Apidog
apidog.com › articles › send-json-object-with-post-request
How to Send JSON Object with POST Request
April 30, 2024 - Navigate to the "Body" tab, choose "json." Notably, you do not need to set the Content-Type header to application/json in Apidog; simply input your JSON data in the provided text box.
🌐
Datawookie
datawookie.dev › blog › 2019 › 01 › json-payload-for-post-request
JSON Payload for POST Request – datawookie
January 10, 2019 - Send the body as a JSON string. POST("https://api.usaspending.gov//api/v2/search/spending_by_transaction/", content_type_json(), body = body)
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Request › json
Request: json() method - Web APIs | MDN
November 7, 2025 - The request body cannot be parsed as JSON. js · const obj = { hello: "world" }; const request = new Request("/myEndpoint", { method: "POST", body: JSON.stringify(obj), }); request.json().then((data) => { // do something with the data sent in the request }); Response.json() Was this page helpful to you?
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-post-json-data-to-server
How to Post JSON Data to Server ? - GeeksforGeeks
August 1, 2024 - A send button for sending the input data to the server. When the user hits the send button it makes a POST request with JSON data to the /data route on the server, and then the server logs the received data.
🌐
Practical Go Lessons
practical-go-lessons.com › post › go-how-to-send-post-http-requests-with-a-json-body-cbhvuqa220ds70kp2lkg
Go: How to send POST HTTP requests with a JSON body| Practical Go Lessons
This teacher variable is then transformed into JSON via json.Marshal. At this stage, marshalled is a slice of bytes []byte, we will use that in our request : req, err := http.NewRequest("POST", "https://example.com/teacher", bytes.NewReader(marshalled)) if err != nil { log.Fatalf("impossible to build request: %s", err) } We build a new request with http.NewRequest, first param HTTP verb, second the URL, and third the body.
🌐
DEV Community
dev.to › serenepine › how-to-send-json-data-in-postman-90a
How to Send JSON Data in Postman - DEV Community
October 20, 2024 - In the request settings, you will find a dropdown menu. Select this menu and set the request type to "POST." This is because we will be sending JSON-formatted data to the server, and POST requests are commonly used for such data transmission.
🌐
HubSpot
community.hubspot.com › t5 › APIs-Integrations › JSON-formatting-on-POST-request › m-p › 810335
HubSpot Community - JSON formatting on POST request - HubSpot Community
June 22, 2023 - import requests def send_nested_json(url, json_data): response = requests.post(url, json=json_data) return response if __name__ == "__main__": url = "https://example.com/api/v1/my-endpoint" json_data = { "nested_field": { "key1": "value1", "key2": "value2" } } response = send_nested_json(url, json_data) print(response.content)
🌐
Retool
community.retool.com › 💬 queries and resources
API REST POST Request body in JSON is treated as string - 💬 Queries and Resources - Retool Forum
March 8, 2024 - I've been trying to setup a POST request in my REST API; however I'm having an issue with the body I send on the request; the body contains a nested object, but the payload is always sent as a string; I've followed the steps mentioned in this article: Perform REST API requests But the same thing happens, no matter how I choose to format the object it is always sent as an escaped string, which prevents my API to actually recognize the body and just returns an empty message.
🌐
ScrapingBee
scrapingbee.com › webscraping-questions › curl › post-json-curl
How to POST JSON using cURL? | ScrapingBee
You can send JSON with a POST request using cURL using the -X option with POST and the -d option (data). Here is a sample command that sends a POST request to our hosted version of HTTPBin with JSON data: curl -X POST https://httpbin.scrapi...