Reputation: 46
While sending documents via external link in telegram bot I am getting error of "Unhandled rejection Error: ETELEGRAM: 400 Bad Request: wrong type of the web page content". I just don't understand why this error occured? P.S I'm using node.js library called node-telegram-bot-api to send requests.
`
bot.sendMediaGroup(
config.CHANNEL_ID,
[
{
type: "photo",
media: imgUrl,
caption: movie,
parse_mode: "HTML",
},
{
type: "photo",
media: screenshots[0],
},
{
type: "photo",
media: screenshots[1],
},
{
type: "video",
media: videoArray[0].url,
},
],
{
disable_notification: true,
}
);
`
Upvotes: 0
Views: 3514
Reputation: 1
The same happened to me. Here is my thought: I think telegram caches the url somehow. In my case, I was sending a file from s3, at first it was not flagged public read access. Telegram gave an error, then I make it public then tried different changes when sending the same url. At the end, when I change the url (basically changing the file name), it worked.
Upvotes: 0
Reputation: 21
There are content types that Telegram does not accept . Like .webp .....
async function downloadAndSaveThumbnail(videoInfo) {
const thumbnailExtension = path.extname(videoInfo.thumbnail).toLowerCase();
if (thumbnailExtension !== '.png' && thumbnailExtension !== '.jpg') {
const savedThumbnailPath = `media/${cleanTitle(videoInfo.title)}.png`;
const thumbnailStream = fs.createWriteStream(savedThumbnailPath);
const thumbnailResponse = await axios.get(videoInfo.thumbnail, { responseType: 'stream' });
await new Promise((resolve, reject) => {
thumbnailResponse.data.pipe(thumbnailStream);
thumbnailStream.on('finish', resolve);
thumbnailStream.on('error', reject);
});
return savedThumbnailPath;
} else {
return videoInfo.thumbnail;
}
}
(by default application/octet-stream)
Upvotes: 0
Reputation: 21
Here's what helped in my situation: I added one slash symbol ("/") where the image link contains only one slash symbol ("/").
In my case it worked.
Upvotes: 1
Reputation: 634
in my case i built an array with images but set two times the root domain for the image source, like this https://something.com/https://something.com/img/asdf.jpg
Upvotes: 0
Reputation: 607
I had the same issue when sending photos via public URLs.
I tried the same request using InputFile as multipart/form-data, and it worked.
https://core.telegram.org/bots/api#inputfile
Maybe not all URLs have the correct MIME type required by Telegram Bot API.
Upvotes: -1
Reputation: 151
In my issue i tried to send webp image in my media group. When i deleted, it morking.
Upvotes: 0