params is for GET-style URL parameters, and data is for POST-style body information. It is perfectly legal to provide both types of information in a request, and your request does so too, but you encoded the URL parameters into the URL already.

Your raw post contains JSON data though. Requests can handle JSON encoding for you, and it'll set the correct Content-Type header too; all you need to do is pass in the Python object to be encoded as JSON into the json keyword argument.

You could split out the URL parameters as well:

Copyparams = {'sessionKey': '9ebbd0b25760557393a43064a92bae539d962103', 'format': 'xml', 'platformId': 1}

Then post your data with:

Copyimport requests

url = 'http://192.168.3.45:8080/api/v2/event/log'

data = {"eventType": "AAS_PORTAL_START", "data": {"uid": "hfe3hf45huf33545", "aid": "1", "vid": "1"}}
params = {'sessionKey': '9ebbd0b25760557393a43064a92bae539d962103', 'format': 'xml', 'platformId': 1}

requests.post(url, params=params, json=data)

The json keyword is new in Requests version 2.4.2; if you still have to use an older version, encode the JSON manually using the json module and post the encoded result as the data key; you will have to explicitly set the Content-Type header in that case:

Copyimport requests
import json

headers = {'content-type': 'application/json'}
url = 'http://192.168.3.45:8080/api/v2/event/log'

data = {"eventType": "AAS_PORTAL_START", "data": {"uid": "hfe3hf45huf33545", "aid": "1", "vid": "1"}}
params = {'sessionKey': '9ebbd0b25760557393a43064a92bae539d962103', 'format': 'xml', 'platformId': 1}

requests.post(url, params=params, data=json.dumps(data), headers=headers)
Answer from Martijn Pieters on Stack Overflow
🌐
Requests
requests.readthedocs.io › en › latest › user › quickstart
Quickstart — Requests 2.34.2 documentation
3 weeks ago - If you’d like to add HTTP headers to a request, simply pass in a dict to the headers parameter.
🌐
W3Schools
w3schools.com › python › ref_requests_post.asp
Python Requests post Method
The post() method is used when you want to send some data to the server. requests.post(url, data={key: value}, json={key: value}, args) args means zero or more of the named arguments in the parameter table below.
Discussions

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
How to pass both file (uploaded) and dict params to POST request in FAST API?
How are you posting the data? What exactly are you sending? More on reddit.com
🌐 r/learnpython
2
1
May 20, 2022
[AF] Handling nested dictionaries with standard python requests library
Basically, this should do you: payload = { 'state': 'PA', 'lat': json.dumps({ 'gt': 39, 'lt': 50 }) } HTTP servers expect a query string like key=value, so when requests parses your multidimensional dict, and encounters a mapping type (i.e., dict, list, tuple, set, etc) it iterates through the object and sets the given key as many times as it needs to. If you loop over a dict, you only get the keys. That's why requests is setting your lat values to gt and lt. There are a few common ways to handle multidimensional data in a query string, one of them is to pass a JSON string, like you are, a more popular one is to use php-like array syntax, like ?lat[gt]=39&lat[lt]=50, which, I believe Django does parse, as well as webargs and maybe some other url parsing libraries. The URI spec has no mention of this sort of thing at all, so in the end it's up to you. You might decide to keep it flat: {'lat_gt': 39, 'lat_lt': 50}. More on reddit.com
🌐 r/flask
5
3
April 12, 2018
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
People also ask

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
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
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
Top answer
1 of 3
453

params is for GET-style URL parameters, and data is for POST-style body information. It is perfectly legal to provide both types of information in a request, and your request does so too, but you encoded the URL parameters into the URL already.

Your raw post contains JSON data though. Requests can handle JSON encoding for you, and it'll set the correct Content-Type header too; all you need to do is pass in the Python object to be encoded as JSON into the json keyword argument.

You could split out the URL parameters as well:

Copyparams = {'sessionKey': '9ebbd0b25760557393a43064a92bae539d962103', 'format': 'xml', 'platformId': 1}

Then post your data with:

Copyimport requests

url = 'http://192.168.3.45:8080/api/v2/event/log'

data = {"eventType": "AAS_PORTAL_START", "data": {"uid": "hfe3hf45huf33545", "aid": "1", "vid": "1"}}
params = {'sessionKey': '9ebbd0b25760557393a43064a92bae539d962103', 'format': 'xml', 'platformId': 1}

requests.post(url, params=params, json=data)

The json keyword is new in Requests version 2.4.2; if you still have to use an older version, encode the JSON manually using the json module and post the encoded result as the data key; you will have to explicitly set the Content-Type header in that case:

Copyimport requests
import json

headers = {'content-type': 'application/json'}
url = 'http://192.168.3.45:8080/api/v2/event/log'

data = {"eventType": "AAS_PORTAL_START", "data": {"uid": "hfe3hf45huf33545", "aid": "1", "vid": "1"}}
params = {'sessionKey': '9ebbd0b25760557393a43064a92bae539d962103', 'format': 'xml', 'platformId': 1}

requests.post(url, params=params, data=json.dumps(data), headers=headers)
2 of 3
18

Assign the response to a value and test the attributes of it. These should tell you something useful.

Copyresponse = requests.post(url, params=data, headers=headers)
response.status_code
response.text
  • status_code should just reconfirm the code you were given before, of course
🌐
Scrapfly
scrapfly.io › blog › posts › how-to-python-requests-post
Guide to Python requests POST method
April 18, 2026 - Master Python requests POST method for sending JSON data, form submissions, and file uploads with proper error handling and authentication techniques. Use requests.post() with JSON parameter for API communication and data transmission
🌐
GeeksforGeeks
geeksforgeeks.org › python › get-post-requests-using-python
GET and POST Requests Using Python - GeeksforGeeks
July 17, 2025 - And in most cases, the data provided is in JSON(JavaScript Object Notation) format (which is implemented as dictionary objects in Python!). ... # importing the requests library import requests # api-endpoint URL = "http://maps.googleapis.com/maps/api/geocode/json" # location given here location = "delhi technological university" # defining a params dict for the parameters to be sent to the API PARAMS = {'address':location} # sending get request and saving the response as response object r = requests.get(url = URL, params = PARAMS) # extracting data in json format data = r.json() # extracting l
🌐
Codecademy
codecademy.com › docs › python › requests module › .post()
Python | Requests Module | .post() | Codecademy
May 15, 2024 - The .post() method sends a POST request to a web server and it returns a response object. ... Learn to analyze and visualize data using Python and statistics. ... Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today. ... **kwargs are any number of dictionary items (named arguments) that are passed in as parameters...
Find elsewhere
🌐
Uomosul
uomosul.edu.iq › computerscience › wp-content › uploads › sites › 13 › 2025 › 05 › requests_post_parameters.pdf pdf
Using requests.post() in Python Detailed Explanation of Parameters and Usage
requests.post() in · Python · Detailed Explanation of Parameters and Usage · Introduction · When using requests.post() in Python, an HTTP POST · request is sent to a specified URL. This type of request · is used to send data to the server, either to store new ·
🌐
Apidog
apidog.com › blog › python-post-request
How to send POST Request in python?
February 2, 2026 - In this example, data is a dictionary containing the data to be sent to the server. If you’re sending JSON data, you can use the json parameter instead, which automatically sets the Content-Type header to application/json. Additionally, the requests.post function can accept several other keyword arguments (**kwargs) such as:
🌐
Leapcell
leapcell.io › blog › how-to-use-python-requests-for-post-requests
How to Use Python `requests` for POST Requests | Leapcell
July 25, 2025 - Whether you're sending form data, JSON, or files, requests provides a straightforward and flexible API to handle these tasks efficiently. Use the json= parameter in requests.post() instead of data=.
🌐
Medium
techkamar.medium.com › sending-form-data-post-using-python-requests-library-55850c7a93d5
Sending FORM data POST using Python Requests library - tech kamar - Medium
June 26, 2024 - import requests url = "http://localhost:8080/login" form_data = {"username":"johndoe", "password": "user@1234"} resp = requests.post(url, data=form_data)
🌐
ReqBin
reqbin.com › code › python › ighnykth › python-requests-post-example
How do I send a POST request using Python Requests Library?
To send a POST request using the Python Requests Library, you should call the requests.post() method and pass the target URL as the first parameter and the POST data with the data= parameter.
🌐
Medium
medium.com › edureka › python-requests-tutorial-30edabfa6a1c
Python Requests Tutorial — GET and POST Requests in Python | by Aayushi Johari | Edureka | Medium
September 10, 2020 - In this tutorial, you will learn how to use this library to send simple HTTP requests in Python. Requests allow you to send HTTP/1.1 requests. You can add headers, form data, multi-part files, and parameters with simple Python dictionaries, and access the response data in the same way.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-requests-post-request-with-headers-and-body
Python requests - POST request with headers and body - GeeksforGeeks
July 23, 2025 - data parameter takes a dictionary, a list of tuples, bytes, or a file-like object. You’ll want to adapt the data you send in the body of your request to the specified URL. ... requests.post(url, data={key: value}, json={key: value}, ...
🌐
datagy
datagy.io › home › python requests › python requests: post request explained
Python requests: POST Request Explained • datagy
December 30, 2022 - Let’s create our first POST request ... back, which returns a Response object. We can pass data into the request by using the data= parameter....
🌐
Tutorialspoint
tutorialspoint.com › python › python_requests_post_method.htm
Python Requests post() Method
It allows sending data to the server which is typically used for submitting forms or uploading files. This method accepts parameters like 'url', 'data', 'json', 'headers', 'cookies', 'files' and 'timeout'.
🌐
ScrapeOps
scrapeops.io › home › python web scraping playbook › python requests post requests
Python Requests - How to Send POST Requests | ScrapeOps
April 12, 2023 - To send POST requests with Python Requests use the requests.post() method and add the POST body and Content-Type using the body and headers parameters.
🌐
AnyIP
anyip.io › blog › python-requests-post
How to make a POST with the Python Requests module?
April 2, 2025 - This last section will show the simple syntax for using the Session object to perform POST requests. It’s efficient to reuse the same session object when making multiple requests to the same server. The session object maintains parameters such as cookies and headers across multiple requests.
🌐
LabEx
labex.io › tutorials › python-how-to-send-data-in-a-post-request-using-python-requests-398065
How to send data in a POST request using Python requests | LabEx
The requests.post() function is used to send a POST request to a specified URL. To include data in the request body, you can pass the data as a parameter to the requests.post() function.
🌐
ProxiesAPI
proxiesapi.com › articles › working-with-query-parameters-in-python-requests
Working with Query Parameters in Python Requests | ProxiesAPI
Yes, query params can be used with any HTTP verb like GET, POST, PUT, etc. What are some common use cases for query parameters? Pagination, filtering, options, non-sensitive metadata.
🌐
ScrapingBee
scrapingbee.com › blog › how-to-send-post-python-requests
How to send a POST with Python Requests? | ScrapingBee
January 11, 2026 - We're still sending JSON the same way as any Python requests POST JSON pattern. Most modern APIs expect JSON instead of traditional form fields. With Requests, the easiest way to send JSON is to use the json= parameter.