I would like to execute an action and wait for the result using the REST API. Is that possible?
⚠️ 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.
It’s possible to trigger an action execution via the API, check POST /api/v1/executions
endpoint https://api.stackstorm.com/api/v1/executions/#/action_executions_controller.post
You have to poll however for action completion, having the id
returned from the previous
POST (create execution) request.
If you’ll try st2 run
, - it has the same polling logic. For example:
st2 --debug run core.local 'sleep 10'
With the debug
flag set, - it will show exactly which API requests st2client
made, including polling for action completion.
You can re-use API requests from this command, - it’ll help you to bootstrap faster having the examples.
I guess this is not called synchronously but thank you for the answer!
Yes, that’s the only way to do it.
API can’t synchronously block and wait for Action to complete until it’s finished, - instead it just
returns an execution id immediately that was triggered.
For example, what if action/workflow is running for hours/days? The response won’t survive the
http/timeouts and won’t be delivered, if we talk about typical API call.
Hence, async.
BTW, there is an event stream one could listen on: https://api.stackstorm.com/stream/v1/stream/#/stream_controller.get_all for different events happening in the platform, incl. executions completion.
Hi,
and what’s about using sensors, I mean, could we get a sync response using sensors (passive mode)? If
no, how would sensor response be? I mean, an empty response like with webhooks or we would get an
execution id like /v1/executions API
Thanks