Answer the question
In order to leave comments, you need to log in
How to correctly convert a request from curl format to Python requests?
Good morning.
I want to make a request to the API, I constantly get an authorization error. What does a curl request look like:
curl \
-H 'Content-Type: application/json' \
-H 'User-Id: %USER_ID%' \
-H 'Authorization: bearer %USER_API_KEY%' \
-d '{"fields":["info","sum","date"],"orders":[{"name":"date","direction":"DESC"}],"limit":"10"}' \
"https://api.topvisor.ru/v2/json/get/bank/history"
POST /v2/json/get/bank/history HTTP/1.1
Host: api.topvisor.ru
Content-Type: application/json
User-Id: %USER_ID%
Authorization: bearer %USER_API_KEY%
{"fields":["info","sum","date"],"orders":[{"name":"date","direction":"DESC"}],"limit":"10"}
import requests
url = 'https://api.topvisor.ru/v2/json/get/bank/history'
headers = {
"Content-type": "application/json",
"User-Id": "111111",
"Authorization": "bearer 11111111111111111111"
}
data = {
"fields": ["info", "sum", "date"],
"orders": [{
"name": "date",
"direction": "DESC"
}],
"limit": "10"
}
r1 = requests.get(url, headers=headers, data=data)
r2 = requests.post(url, headers=headers, data=data)
{"error":true,"message":"not exists POST: \"api_key\""}
Answer the question
In order to leave comments, you need to log in
If you have gulp 4, then maybe you forgot to use the parallel or series functions
There was an internal problem of the service (redirect to the previous version of the API), the code worked, everything is fine :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question