Is the Telegram script failing?

Hi, for the past 3 days I've been having problems sending notifications via Telegram, possibly due to the Telegram API and scripts that have been working for 3-4 years. Now I'm getting this error:
failure: Status 400, Bad Request (/tool/fetch; line X).

Script:

:local BotToken "XXXXXXXXXX:XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXX"
:local ChatID "XXXXXXXXX"
:local parseMode "HTML"
:local DisableWebPagePreview True
:local SendText $MessageText

/tool fetch url="https://api.telegram.org/bot$BotToken/sendMessage\3Fchat_id=$ChatID&parse_mode=$parseMode&text=$SendText&disable_web_page_preview=$DisableWebPagePreview" keep-result=no

Has anyone else who uses this type of notification experienced something similar?
Thanks.

December 29, 2023

Replaced the field disable_web_page_preview with link_preview_options

Just a wild guess.

Yes, I've this problem too

I saw a message that started complaining about using spaces in text. Try replacing it with %20 or +

That makes sense; it's possible the Telegram API has new rules for recognizing spaces or other characters. Any advice on how to convert those spaces in any text from within the Mikrotik script itself?

Edit:
:local SendText "Hello%20world" -- Working
:local SendText "Hello+world" -- Working
:local SendText "Hello world" -- Not working (failure: Status 400, Bad Request)

Thx.

Add this at the end

keep-result=no http-method=post mode=https

There is :convert function. If you use it with to=url parameter, it will do the job.

[admin@test] > :put [:convert "Hello world" to=url]
[admin@test] > Hello%20world

Personally, I use it to send Telegram notifications. It will convert other symbols to URL-compatible format too.

just add http-percent-encoding=yes to the fetch command.

7.21:
*) fetch - added "http-percent-encoding" parameter;