This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Access POST data in webhook

Hello, I’m very new to stackstorm and the last few days I was looking in the documentation and the forum for information regarding the different kindes of variables.

I have a webhook and am posting data to the url like

curl -X POST -H “[api-key]” -d “{“key1”:“value1”}” // from Windows

But how do I access this “key1” value in the action of my webhook?

I have something like this:


“action”: {
“ref”: “core.echo”,
“parameters”: {
“message”: “print {{ key1 }}”
},

Does anybody have more information regarding all kinds of available variables and specially the ones that are transmitted using a webhook?

Regards
Harald

You can access the incoming webhook body data using {{ trigger.body.foo }} notation inside the rule.

For example, in your scenario that would be {{ trigger.body.key1 }}.

Keep in mind that you also need to pass correct “Content-Type: application/json” header when sending your webhook data using curl, otherwise StackStorm won’t parse body as JSON, but will treat it as raw string (so the notation mentioned above won’t work, because {{ trigger.body }} will contact the whole body as a string).

So:

curl -X POST -H "[api-key]" -H "Content-Type: application/json" -d “{“key1”:“value1”}” // from Windows

That’s also documented here - Webhooks — StackStorm 3.1.0 documentation.

Hello Tomaz,

thank You very much! This was the part I was missing: {{ trigger.body.key1 }}
It works now as expected.

Kind Regards
Harald