skip to Main Content

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?

4

Answers


  1. Chosen as BEST ANSWER

    Resolved :

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

  2. It should be:

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

    https://github.com/yagop/node-telegram-bot-api#TelegramBot+sendPhoto

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search