B. Azizan B. Azizan - 6 months ago 103
Node.js Question

Node Telegram Bot API return error 400

I was wrote a Telegram bot with Nodejs. To send an image to the user I am using the following commands :

bot.sendPhoto({
chat_id: msg.chat.id,
caption: 'Test caption',
files: {
photo: '../change-db-shop-url.png'
}
}, function (err, msg) {
console.log(err);
console.log(msg);
});


This error displayed :


Unhandled rejection Error: 400
{"ok":false,"error_code":400,"description":"Bad Request: there is no
photo in the request"}


Can you help me?

Answer

Resolved :

var photo = __dirname+'/../Android.png';
bot.sendPhoto(msg.chat.id, photo, {caption: "I'm a bot!"});