0

I am using this query to edit my message's text and reply markup keyboard. https://api.telegram.org/bot${tgBot}/editMesssageText?chat_id=${chatContext}&message_id=${originMessageID}&text=${message}&parse_mode=HTML&reply_markup={"inline_keyboard":[[{"text":"New Project","callback_data":"startInstall"}]]}

Using a URL query inspection tool, this is what I get - again, values are what they should be. URL Inspection App Results - all being exactly what they should be - but still returns error 404 - Not Found

My bot token has "bot" before it in the url. The values should be exactly what they should be. I am using the correct chat_id and message_id. I am pretty sure the inline keyboard is formatted correctly. I use this same method somewhere else in my code and that works, so I'm not sure why this isn't.

For reference, this is the working method call:

https://api.telegram.org/bot${tgBot}/editMessageText?chat_id=${chatContext}&message_id=${originMessageID}&text=${message}&parse_mode=HTML&reply_markup={"inline_keyboard":${keyboardButtons}

And this is an inspection of its values. For clarification, this method is called when the user has projects in their user document, so there is supposed to be an example project in the buttons: Working API Method Call Inspection - Returns Status 200 - OK

I have no idea what else to try at this point.

fettuccine
  • 33
  • 5

1 Answers1

0

I GOT IT WORKING!!

I still am not sure EXACTLY what the root issue was, but I made a function to send these requests as I wanted to make sure I wasn't misspelling something simple and it just started working.

In case anyone runs into this same issue, this was my function.

async function editMessage(botToken: string, chatId, messageId, text: string, parseMode, replyMarkup) {
  if (replyMarkup == undefined) {
    const res = await fetch(
      `https://api.telegram.org/bot${botToken}/editMessageText?chat_id=${chatId}&message_id=${messageId}&text=${text}&parse_mode=${parseMode}`
    )

    return res
  } else {
    const res = await fetch(
      `https://api.telegram.org/bot${botToken}/editMessageText?chat_id=${chatId}&message_id=${messageId}&text=${text}&parse_mode=${parseMode}&reply_markup=${replyMarkup}`
    )
    
    return res
  }
}
fettuccine
  • 33
  • 5
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 11 '22 at 13:53