I want to send a simple jpg
file ~30kb via telegram bot.
I have a camera that takes surveillance videos and creates thumbnails of them (Synology Surveillance Station).
These thumbnails are provided by the station at a specific URL like.
https://mystation.synology.me:5001/webapi/SurveillanceStation/Webhook/GetThumbnail/v1/<some-token>/thumbnail.jpg
When i open the URL in the browser a download of the thumbnail.jpg starts. (maybe thats already why it isn’t working)
So when i try to send a POST request with Postman
POST https://api.telegram.org/bot<token>/sendPhoto
Content-Type: application/x-www-form-urlencoded
chat_id: 123456789
photo: https://mystation.synology.me:5001/webapi/SurveillanceStation/Webhook/GetThumbnail/v1/<some-token>/thumbnail.jpg
then i get the error
{
"ok": false,
"error_code": 400,
"description": "Bad Request: wrong file identifier/HTTP URL specified"
}
So can it be that it does not work because the URL starts a download? If I now take example images like https://telegram.org/img/t_logo.png
it works fine. So it must have something to do with the URL.
Or is there another method that can do this?
2
Answers
Your right, Telegram expects an url that serves the image, not an uri that forces a download (probably using the
Content-Disposition
header)You should save the the image on your server, and then send them as a local file.
Method 1: Upload the image file to Telegram using the multipart/form-data content type:
Method 2: Pre-upload the image to Telegram and use the file identifier: