Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Telegram Support

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Telegram Support


    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());
    }

    }​

    #2
    Hello greenhollow803,

    What you are seeing is a server error meaning the server you contacted returned that error. Bad request would generally mean in some way the request you made was malformed. To know what the problem is you would need to look at the URL, Parameters and other details of what you made and then check what is required by telegram. You can compare what you made to their API documentation. Based on that observation you can potentially make out what the problem is. External services like telegram are outside of what our support can specifically help with so you may want to also post this error in the thread you had linked for additional help.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for a quick response. I missed &text= which caused the issue. Now it worked after fixing the url format

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,406 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      98 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      8 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      160 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      9 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X