skip to Main Content

I’m currently testing some indicator/strategy and would like to automate things.
I configure somes webhook with alerts with JSON formated strings like :

alert("{'heyyy':'oohhhh!'}", freq = alert.freq_all)  

but when the alert is triggered, webhook sended and i reveive the call on my server (node.js), the body is empty : {}

i setup the alert on "every alert() call"

i also try with alertcondition but the result is the same : empty body.

Thanks

2

Answers


  1. Chosen as BEST ANSWER

    I figure how to do that, there were a few issues

    1 - We must use simple quote as wrapper and double quotes for properties in stringify JSON

    str = "{'hey':'oh!'}" // bad
    str = '{"hey":"oh:"}' // good
    

    2 - server side (node JS) my body parser is now setup to receive plan text too

     app.use(bodyParser.text({ type: "*/*" }));
    

    Note, if your JSON string is setup with the wrong quotes , the JSON.parse() won't work


  2. Try log.info to test you alert mesage

    msgAlert = "{'heyyy':'oohhhh!'}"
    if testcondition and barstate.isconfirmed
        alert(msgAlert, freq = alert.freq_once_per_bar_close)
        log.info("n{0}", msgAlert)
    

    your string looks good

    enter image description here

    It doesn’t seem like a pinescript problem

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search