0

I need to send data via python post request to service named amplitude, they give curl example, that I tried to rewrite on python and getting 400 error.

curl example

curl --data 'api_key=040062a5d38552315b98302ba4f2f' --data 'identification=[{"device_id":"device_id_of_user", "user_properties":{"Cohort":"Test A"}}]' https://api.amplitude.com/identify

my python code

url = 'https://api.amplitude.com/identify'
data = '{"api_key":"myapi_key", "identification":[{"device_id":"dev_id", "user_properties":{"value1": 26, "value2": 17, "class1": "normal 22+", "class2": "normal2", "class3": "3-7p"}}]}'

r = requests.post(url, data= data)

And as I understand my problem, in curl there is 2 data field and I'm sending only one and I can't find how to send multiple same fields.

The question, is how to make it in the proper way?

  • 1
    See [How to send POST request?](https://stackoverflow.com/questions/11322430/how-to-send-post-request). The accepted answer shows you how using the `requests` library, the second highest voted answer sticks to the standard library. Both work with any amount of data. – glibdud Oct 23 '19 at 12:15
  • yes you right, tried and it workds – Максим Усик Oct 23 '19 at 12:32

0 Answers0