Inserting variables into the payload of the http-Connector

I can send variables in the payload when hard wired such as

{“name”: “Throw_a_signal”,
“variables”: {
“weather” :{
“type”: “string”,
“value” : “sunny”
}
}
}

But I’m having trouble inserting variables from the process.

I know I can use execution.getVariable(“weather”) but how do I insert that in the json structure?

Create a script for your payload of the http connector. Use JavaScript as your script type. And you can create a Json object. You can then stringify the result of the script

1 Like

Thanks StephenOTT that worked a treat. Is there a simple way to add all Variables?

execution.getVariables() which sould return a Map. You can then covert your map to a JS object. see https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions for different ways to convert from Java Objects to JS.

can you please share the code you have used ?