Answer the question
In order to leave comments, you need to log in
Sending photo with caption option telegram api?
I try to fasten to such code, the description of a file.
caption (str, optional) msg = {'caption' : 'hello'}
url = «https://api.telegram.org/bot<token>/sendPhoto»;
files = {‘photo’: open(‘avatar1459.jpg’, ‘rb’)}
data = {‘chat_id’ : «-100134»}
msg = {‘caption’ : ‘hello’}
r= requests.post(url, files=files, data=data, msg=msg)
print(r.json())
Answer the question
In order to leave comments, you need to log in
To resolve the issue, it is enough to remove the msg parameter and add the required 'caption' parameter to the data dictionary.
Final solution:
url = ' https://api.telegram.org/bot ' + token + '/sendPhoto'
file = {'photo': open('avatar1459.jpg', 'rb')}
data = {'chat_id ': -100134, 'caption': 'hello'}
r = req.post(url, files=file, data=data)
By the way, thanks for the hint with the question))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question