Send photos to a Bot telegram with Rundeck

52 Views Asked by At

I'm using Rundeck for some automation and i already use it to send messages with a bot to a specific Telegram Grops.

I do it using a

"HTTP Request Step" with "https://api.telegram.org/<BOT>/sendMessage"

and 2 input options

{ "chat_id": "${option.chatid}", "text": "${option.corpo}" } It works perfectly!

Now I'm trying to evolve it sending photos with:

https://api.telegram.org/<BOT>/sendPhoto And this 3 input options { "chat_id": "${option.chatid}", "text": "${option.corpo}", "file": "${file.file}" }

The file option is a "File" type.

the error that appears is:

{ "ok": false, "error_code": 400, "description": "Bad Request: there is no photo in the request" } Error when sending request: Attempted read from closed stream.

Do you have some tips? Thank you!

Miglio

I've tried to use "photo" and not "file" in the body of the option, but it doesn't works.

1

There are 1 best solutions below

0
0stone0 On
  1. The sendPhoto method does not have a file paramater, you'll need to pass the photo to the photo parameter.
  2. There is also no text parameter, that's called caption on sendPhoto

Not an rundeck expect but seems like you'll need something like:

  • filephoto
  • textcaption
{ "chat_id": "${option.chatid}", "caption": "${option.corpo}", "photo": "${file.file}" }