W
W
windf1n2021-05-15 11:33:01
Python
windf1n, 2021-05-15 11:33:01

Error 418: I'm a teapot when connecting to the KazanExpress API. What is the reason?

I'm trying to get data about the store using the KazanExpress API in this way:

headers = {
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
    'Authorization': 'Basic НЕСКАЖУ'
}

login = requests.post('https://api.kazanexpress.ru/api/oauth/token?grant_type=password&username=НЕСКАЖУ&password=НЕСКАЖУ, headers=headers)

print(login.json())

headers.update({
    'Authorization': 'Bearer ' + login.json()['access_token']
})

shops = requests.get('https://api.kazanexpress.ru/api/seller/shop/', headers=headers)
print(shops.json())


The result is this: the login variable works fine and receives the necessary data. And the variable shops gives an error:
{'timestamp': 1621067445165, 'status': 418, 'error': "I'm a teapot", 'message': "I'm a teapot", 'path': '/api/seller/shop/'}


However, in some magical way, this code sometimes works and sometimes doesn't...

How can I fix this error?

Addition:
I specify user-agent to receive data, without this header returns an empty array.
The API may be closed, but there are applications and bots in Telegram that work perfectly with the KazanExpress API.

UPD:
I noticed through the Network tool in Google Chrome that the request is first made through OPTIONS, and then through GET

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2021-05-15
@firedragon

Put any running application and set up fiddler then watch the application traffic and modify yours

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question