Hi,
I follwed the instructions given at the below thread to send a text message to Telegram from the script.
I am able to successfully invoke Telegram web link. So that API TokenId and Chat Id are working fine. However when I invoke from an indicator script, I get the below error. Any suggestions on how to make it work?
11/16/2023 12:10:48 PM System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
Below the code how I am invoking.
private void SendTelegramTextMessage(string Msg)
{
string url = @"https://api.telegram.org/botAPI TOKENXXXX/sendMessage?chat_id=CHATIDXXX" +Msg;
try{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url) ;
HttpWebResponse res = (HttpWebResponse)request.GetResponse();
}catch(Exception e){
Print(Time[0] + " " +" "+ e.ToString());
}
}
Comment