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.

How to put variable in JSON body of core.http?

This workflow works:
version: 1.0
tasks:

[555, 191]

task1:
action: core.http
input:
url: <% st2kv(‘system.t20-url’) %>/equipment/actions/<% ctx(‘action’) %>
body: “{“id”:“60ac004413e4a00082c96bbd”}”
method: POST
headers:
Content-Type: application/json

input:

  • equipmentId
  • action

But I do not want to hard code the id in the body, I want to use the ctx(“equipmentId”) variable. How can I use that variable, but still send the body as JSON? It seems like http.core requires the body to be a string.

Here is what I have tried:
“{“id”:<% ctx(“equipmentId”) %>}”
<% ‘{“id”:"’ ctx(“equipmentId”) ‘"}"’ %>
‘{“id:”’<% ctx(“equipmentId”)%>’"}’

They all fail with some parsing error.

I figured it out:

body: <% concat(’{“id”:"’, ctx(“equipmentId”), ‘"}’) %>

lol