params is for GET-style URL parameters, 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:

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

then post your data with:

import 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:

import 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
🌐
Real Python
realpython.com › python-requests
Python's Requests Library (Guide) – Real Python
July 23, 2025 - To add headers to requests, pass a dictionary of headers to the headers parameter in your request. To send POST data, use the data parameter for form-encoded data or the json parameter for JSON data.
Top answer
1 of 3
453

params is for GET-style URL parameters, 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:

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

then post your data with:

import 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:

import 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.

response = 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
🌐
Requests
requests.readthedocs.io › en › latest › user › quickstart
Quickstart — Requests 2.32.5 documentation - Read the Docs
That’s all well and good, but it’s also only the start of what Requests can do. You often want to send some sort of data in the URL’s query string. If you were constructing the URL by hand, this data would be given as key/value pairs in the URL after a question mark, e.g.
🌐
W3Schools
w3schools.com › python › ref_requests_post.asp
Python Requests post Method
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST
🌐
Python-requests
docs.python-requests.org › en › latest › user › quickstart
Quickstart — Requests 2.33.0.dev1 documentation
That’s all well and good, but it’s also only the start of what Requests can do. You often want to send some sort of data in the URL’s query string. If you were constructing the URL by hand, this data would be given as key/value pairs in the URL after a question mark, e.g.
🌐
Reddit
reddit.com › r/learnpython › i don't really understand requests python module
r/learnpython on Reddit: I don't really understand Requests python module
February 3, 2022 -

https://www.youtube.com/watch?v=tb8gHvYlCFs&t=374s

I am watching this vid, all excited to learn requests, but I don't really understand nearly anything, like what is r.content doing, or the r.json() function does I also don't get what

what is in r.content, it returns things, but I don't really understand what these things are, r.text returns a dictionary of args, headers, origin etc but I don't really get how this information is useful.

r.get, r.post, or r.put really do I am really sorry for this but if someone could link an article or a little video that explains what the content is, like I am not sure what to search for.

🌐
W3Schools
w3schools.com › python › module_requests.asp
Python Requests Module
The requests module allows you to send HTTP requests using Python. The HTTP request returns a Response Object with all the response data (content, encoding, status, etc).
Find elsewhere
🌐
PyPI
pypi.org › project › requests
requests · PyPI
There’s no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! Requests is one of the most downloaded Python packages today, pulling in around 30M downloads / week— according to GitHub, Requests is currently depended upon by 1,000,000+ repositories.
      » pip install requests
    
Published   Aug 18, 2025
Version   2.32.5
🌐
GeeksforGeeks
geeksforgeeks.org › get-post-requests-using-python
GET and POST Requests Using Python - GeeksforGeeks
August 12, 2024 - A web browser may be the client, and an application on a computer that hosts a website may be the server. So, to request a response from the server, there are mainly two methods: GET: To request data from the server.
🌐
Bright Data
brightdata.com › blog › web-data › python-requests-guide
Master Python HTTP Requests: Advanced Guide 2026
November 20, 2025 - Note: As of version 2.32.5 (2026-08-18), Requests includes important security fixes (e.g., CVE-2024-47081), reverts problematic SSLContext caching introduced in earlier versions, and drops support for Python 3.8. These changes affect how you configure SSL, host validation, and which Python versions you can use. The easiest and recommended way to install Requests is through pip. In particular, the pip package associated with the Requests library is requests. So, you can install the HTTP client with the following command: ... Awesome! The Requests package is now installed and ready to be used. ... Making HTTP requests to web servers: Retrieve data from web servers by sending GET requests.
🌐
Scrapfly
scrapfly.io › blog › posts › how-to-python-requests-post
Guide to Python requests POST method
September 26, 2025 - It allows for customizable and straightforward data sending by specifying the URL, headers, and the data itself. The most common data types include JSON, form data, or raw body data, all handled easily with python requests POST method.
🌐
Requests
requests.readthedocs.io
Requests: HTTP for Humans™ — Requests 2.33.0.dev1 documentation
There’s no need to manually add query strings to your URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling are 100% automatic, thanks to urllib3. Requests is ready for today’s web. ... Requests officially supports Python 3.9+, and runs great on PyPy.
🌐
ProxiesAPI
proxiesapi.com › articles › sending-data-in-get-requests-with-python-requests
Sending Data in GET Requests with Python Requests | ProxiesAPI
December 29, 2016 - import requests url = 'https://api.example.com/data' payload = {'key1': 'value1', 'key2': 'value2'} response = requests.get(url, params=payload) print(response.url) # https://api.example.com/data?key1=value1&key2=value2
🌐
Medium
techkamar.medium.com › sending-form-data-post-using-python-requests-library-55850c7a93d5
Sending FORM data POST using Python Requests library - tech kamar - Medium
July 12, 2025 - http://localhost:8080/login is the end point I want to hit with username and password as form data. ... import requests url = "http://localhost:8080/login" form_data = {"username":"johndoe", "password": "user@1234"} resp = requests.post(url, data=form_data)
🌐
ZetCode
zetcode.com › python › requests
Python Requests - accessing web resources via HTTP
October 28, 2022 - Python Requests tutorial introduces the Python Requests module. We grab data, post data, stream data, and connect to secure web pages.
🌐
Python
docs.python.org › 3 › library › urllib.request.html
urllib.request — Extensible library for opening URLs — Python ...
December 5, 2024 - This class is an abstraction of a URL request. url should be a string containing a valid, properly encoded URL. data must be an object specifying additional data to send to the server, or None if no such data is needed.
🌐
Oxylabs
oxylabs.io › blog › python-requests
Python Requests Library: 2026 Guide
April 16, 2023 - To use a bearer token with Python's requests repository, we can include it as a header in our HTTP requests. Here's an example of using a bearer token to send a GET request to an API: ... import requests url = 'https://example.com/api/data' token = 'Bearer my_access_token' headers = {'Authorization': token} response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json() print('Data retrieved successfully') else: print('Error retrieving data:', response.text)
🌐
DigitalOcean
digitalocean.com › community › tutorials › getting-started-with-python-requests-get-requests
Getting Started With Python Requests - GET Requests | DigitalOcean
September 15, 2020 - The generic process is this: a client (like a browser or Python script using Requests) will send some data to a URL, and then the server located at the URL will read the data, decide what to do with it, and return a response to the client.
🌐
GeeksforGeeks
geeksforgeeks.org › python › response-json-python-requests
response.json() - Python requests - GeeksforGeeks
July 31, 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())
🌐
DataCamp
datacamp.com › tutorial › making-http-requests-in-python
Getting Started with Python HTTP Requests for REST APIs | DataCamp
September 26, 2025 - The Python requests module enables developers to write code to interact with REST APIs. It allows them to send HTTP requests using Python without having to worry about the complexities that typically come with carrying out such tasks (i.e., manually adding query strings to URLs, form-encoding ...