Variables for rest call from bpmn


I’ve deployed the Dinner decision table from the get-started pages, onto an EC2 server and I want to call it from a BPMN process I’m running locally.

I looked at the example for Rest calls for calculating whether it’s a holiday on github. Where I’m stuck, is that this example didn’t have a payload. With the dinner decision table I need to pass through the number of guest and the season:-

  "variables": {
    "season": {"value":"Spring","type":"String"},

From the BPMN file I’ve got this:-

            <camunda:inputParameter name="url">

            <camunda:inputParameter name="method">

            <camunda:inputParameter name="headers">
                <camunda:entry key="Accept">
            <camunda:inputParameter name="variables">
                <camunda:entry key="???">

Can someone point me to a reference for doing this in the BPMN file or just show me the format which also includes using process variables and not actually hard-coding Spring and 2 guests.

Finally, generally speaking why are all the examples in java? Isn’t the plus part of BPMN that you can change the diagram to change the process? Not a criticism, just trying to learn.



@theHornet take a look at this:

When using the HTTP-Connector, you use “payload” in the connector’s input parameter.
Create a JSON string for the returned value of payload using JS or Groovy.

Can also take a look at:

the above provides a working example of a POST web service call, building a JSON payload, and parsing the response.

Edit: Also review: Evaluate Decision |, as Evaluate is a POST endpoint, but your method is currently set to GET.

1 Like

I’m confused as to what you’re asking here. Are you asking what a payload would look like to invoke the “dinner” example (I’ve worked with that also) or are you asking how to code variable inputs in the BPMN code itself?

The Dinner example outputs some things to the system/server log (essentially a deployment check to ensure that the deployed DMN is viable), but also returns a response to a REST request to the DMN when you ask to evaluate a set of inputs.

Hi mppfor_manu, Steve

I was asking for both, The dinner decision service works when I call it using chrome’s Advanced Rest Client. It’s now a case of working how how to call that decision service from a locally executed process.

I thought that I would be coding everything inside of the BPMN but Ive obviously been working with a very old version of Camuda Modeler (now rectified) and I wasn’t aware until I read Steve’s post that you can set this inside the modeler.

I was able to call the decision service using hard coded values the following way (confirmed by checking the cockpit on the amazon server)

When I tried various combinations on the example in the post to pass through the variables into the script with this:-

I wasn’t able to get through to the decision service. (BTW what does the “q” bit mean?)

I’m still working through this (slowly) so I might get some more answers (and questions) later, especially when it comes to processing the output of the decision (desiredDish).



Hi Anthony,

the guest count should be integer.

Hope this helps, Ingo

Also @theHornet your life will be much happier if you build your JSON as a Js Object with dot notation, and then convert with JSON.stringify(); at the end. Much easier to maintain.

1 Like

Thanks Ingo,

That is correct as the type for guestCount is specified as an integer, however the payload i used (pasted from above) in Chrome Advanced Rest Client worked fine. The call from the local process to the cloud decision works as well (with the hard-coded payload version) as checking on the cloud cockpit I can see that it was called and that the correct output was returned.

Duly noted Stephen.

I’m working on processing the response from the decision table. From Chrome’s Advanced Rest Client for the above request I get back the following:-

"desiredDish": {
"type": "String",
"value": "Stew",
"valueInfo": {}

However using the example that you supplied in your link and modifying it for this example, I used the following:-

    <camunda:outputParameter name="grub">
	<camunda:script scriptFormat="JavaScript"><![CDATA[S(response).prop("desiredDish").elements().get(0).prop("value").value();]]></camunda:script>

But unfortunately I’m just getting the following back in my local host process when I try and call the decision

The process could not be started. :
SPIN/JACKSON-JSON-01004 Unable to find 'desiredDish'

Any pointers?



It is because you have a array of objects. doing response.prop(desiredDish) cannot be found because desiredDish is not a property in response

If you are always getting only 1 object in your array, then just set it so you get the first item in the array. response.elements().get(0)

@theHornet review this further:

1 Like

Thanks again Stephen, much appreciated.

By using response.elements().get(0) I got rid of that message, and in fact was able to load the contents of the response payload into the variable “grub”.

From the first link, I’ve tried a few combinations on top from the link you provided such as:-

var json = S(response).elements().get(0);
var customerProperty = json.prop("desiredDish");
var customers = customerProperty.elements();
var customer = customers.get(0)
var grub = customer.value();

and got the following message:-

The process could not be started. :
SPIN/JACKSON-JSON-01002 Expected 'SpinList', got 'OBJECT'

Combinations on the inline script brought back the same error number 01002. I think that I’ll be able to extract the value using an external javascript file, but it’s a pain.

Thanks again.

@theHornet you need to read the JSON Spin documents, and read up on the difference between a JSON Object and JSON array. you are using var customers = customerProperty.elements(); which is trying to get the array elements, but customerProperty is a object and so .elements() is not correct.

Should be something like:

var grub = S(response).elements().get(0).prop("desiredDish").prop("value").value();


Yes, that worked a treat. I’m not a programmer more of a tinkerer but I can see that I’m going to have to understand this difference between JSON objects and arrays.

I am using the parameter “var json = S(response, ‘application/json’);”, as the output of my connector, but I would like to filter the result, instead of show all the Json. Do you know you to filter the result?

This is the Json returned.
“nomeCliente”: “Andre Sousa”,
“documentoCliente”: “123456789”,
“codOrigem”: “332”,
“nomeCliente”: “Lucas Rodrigues”,
“documentoCliente”: “111111111”,
“codOrigem”: “112”,

Rudson R.

@Rudson_Rodrigues it would be good for you to spend some time reading over the SPIN documentation:

Quering/Filtering JSON:

Spin Docs:


I got the answer in the link you mentioned.
Thanks a lot!