#How to send message to telegram bot api

1 messages · Page 1 of 1 (latest)

fluid patrol
#

My worker is returning {ok: false, error_code: 400, description: 'Bad Request: message text is empty'} when I make an API call to Telegram.

However, I don't see any problems with my fetch request within my worker. What am I missing in my fetch function?

const sendMessage = async (message) => {

  const token = '--'
  const data = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
    method: "POST",
    body: JSON.stringify({
      chat_id: "---",
      text: message
    })
  })

  return await data.json()
}
dusk atlas
#

Try adding a Content-Type: application/json request header

fluid patrol
#

life saver man

#

the little things, always