python requests post list

Python Requests Post List

If you want to send a list of items to a server using Python, you can use the requests module to make a POST request. A POST request is used when you want to send data to a server. In this case, we want to send a list of items.

Step 1: Import the Requests Module

The first step is to import the requests module:

import requests

Step 2: Create the List

Next, let's create a list of items:

items = ['item1', 'item2', 'item3']

Step 3: Send the POST Request

Now we can send the POST request using the requests module:

url = ''
data = {'items': items}
response =, json=data)

In this example, we are sending the list of items to the URL "". We are using the "json" parameter to send the data as a JSON object.

Step 4: Check the Response

We can check the response from the server using the "response" object:


This will print the response from the server.

Alternative Way: Using Form Data

Another way to send a list of items is using form data instead of JSON. Here is an example:

url = ''
data = {'items[]': items}
response =, data=data)

In this example, we are using the "data" parameter instead of the "json" parameter. We are sending the data as a form data object. Notice that we are using "items[]" instead of "items". This is because we want to send a list of items.


In conclusion, there are two ways to send a list of items using the requests module in Python. You can either send it as a JSON object or as form data.