I
I
Ivan Yakushenko2019-05-30 21:22:15
Python
Ivan Yakushenko, 2019-05-30 21:22:15

What causes the 'Request Entity Too Large' error when sending an image to Telegram?

File size: 51.2 KB
Trying to send:

>>> send_img_url = 'https://api.telegram.org/botXXXXXXXXXXXXXXXXXXXXX/sendPhoto'
>>> img_name = 'C:/Users/Administrator/Downloads/WhatsApp Image 2019-05-30 at 20.54.40.jpeg'
>>> r = requests.post(send_img_url, data={'chat_id': '-351543550', 'photo': open(img_name, 'rb')})
>>> r
<Response [413]>
>>> r.reason
'Request Entity Too Large'
>>> r.content
b''
>>>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-05-31
@kshnkvn

Because the files are sent wrong .

r = requests.post(send_img_url, data={'chat_id': '-351543550'}, files={"photo": open(img_name, 'rb')})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question