Home > database >  How can I get the data from an API using Python Request Post?
How can I get the data from an API using Python Request Post?

Time:09-23

I'm trying to retrive some data from apptopia but I'm finding it pretty tricky (due to my lack of experience). In their authentication page: https://dev.apptopia.com/#authentication there are some instructions, but I just can't make it work.

I need a client and a secret (these bellow are not mine but the ones on the company's site)

client: JFqXPDhiLuvY
secret: L2nerprCksacBoFzUqtfHz8v

And I must use those information in order to obtain a Session token via HTTPS POST request:

curl -X "POST" "https://integrations.apptopia.com/api/login" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "client=<client>" \
  --data-urlencode "secret=<secret>"

I just don't know how to do it. I tried using the answen on this post: Python Request Post with param data but it didn't work. Could someone help me please? Thanks!

CodePudding user response:

Did you try passing credentials as data in your request?

import requests

headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'client':your_client,
    'secret':your_secret'
}

response = requests.post('https://integrations.apptopia.com/api/login', headers=headers, data=data)
  • Related