How do I send & receive JSON request while calling a external REST from within the BPMN

I see an example at : location but this is using java script.

I DO NOT want to to use Java script instead I want to do it this way.

  1. Before the service task is called I will have the JSON created and stored in the execution context.
  2. Use that as Input variable in my REST Call
  3. Assigne the Response from the a REST call directly to a java Object or may be JSON String.
  4. Which I can access further to take some decision, etc.

An example which explains this feature?

1 Like


I would recommend having a look at the connector capability [1]

You can use a service task with a connector to call your REST API. In the configuration of the connector (in modeller), you could use expresion language to reference a process variable which contains your JASON payload eg payload=${MyPayload}. In addition, you can use the connector to set a response value as a process variable

You can use a service task to build your jason payload then set it as a process variable eg, execution.setVariable(“MyPayload”,MyJSON)

Another option you could consider is use a freemarker template to build your JSON payload. The template can reference process variables to build a complete payload.



Thanks for your response. I got your point however, I am not completely aware of how to put the JSON payload into the process.

As in lets say I am getting a variable as part of the payload while a Camunda process is instantiated, does it automatically become a process variable?

Or I have to do something like this
execution.setVariable(“MyPayloadToExternalCALL”, “processPayloadWhileStartingProcess”)

I have another query regarding the same in this forum as below, may be your answer will answer both.


No problem - heres a few more tips. Heres a reference to how to create a JSON payload using a form submission [1]

Hence on submitting the form, you will have a process instance variable called customer which contains the JSON structure. Note in your form, you can use the JSON struct as an angular model so you can manipulate the attributes via html inputs. Theres also a link to a more full example in these docs…

Hope that gets you started. Feel free to ask more questions…


I completely get your point on how we process or use json inside the script or delegate classes.

My question is more around a specific requirement I am trying to implement.

  1. I want to send a Custom JSON while calling the REST service “ProcessName/start” as a payload

  2. I want to use the above JSON custom data in my decision makings (I saw a EL expression for this, this should work, provided my JSOn payload exist in the execution context)

  3. Pass “another” json object in the service task (I dont want to use javascript) as dont have any TaskForms

  4. Get the json response and store it into another process variable

Can you guide on the above, with some sample code if any?


To answer your questions;

1 - No problem. The REST API start process can take a JSON variable as part of the JSON payload in the API request. You may need to be careful how you encode your JSON variable, eg you may need to escape double quotes as you will effectively have a serialized JSON variable inside the request JSON payload. Reference in the docs can be seen in [1]

Heres some sample json encoded in a POST for the REST API…

{“POI” : {“value” : “[{“credentialType” : “Australian Birth Certificate”, “disposition”: “current”,“classification”:0,“expiryDate” : “2013-01-01T23:28:56.782Z”},{“credentialType” : “Australian Passport”, “disposition”: “Cancelled”,“classification”:0,“expiryDate” : “2012-01-01T23:28:56.782Z”},{“credentialType” : “Utility Bill”, “disposition”: “current”,“classification”:0,“expiryDate” : “2013-01-01T23:28:56.782Z”},{“credentialType” : “Utility Bill”, “disposition”: “current”,“classification”:0,“expiryDate” : “2013-01-01T23:28:56.782Z”}]”, “type” : “json”},
“SUBJECT” : {“value” : “{“givenNames” : “John Andrew”, “surname” : “Citizen”, “title” : “Mr”, “contact” : {“email” : "”,“mobile” : “0455555555”}, “residentialAddress” : {“suburb” : “Melbourne”, “state” : “VIC”, “postcode” : “3000”}, “DOB”:“01/01/1990”}", “type” : “json”},
“anotherVariable” : {“value” : true, “type”: “Boolean”}},
“businessKey” : “myBusinessKey”

2 - From above, you should have a process instance json variable which you can reference by name. So yes you could use expression and even use properties deep in the json structure eg; ${SUBJECT.prop(“residentialAddress”).prop(“suburb”) == “Melbourne”}

3 - Not sure what you mean, can you clarify?

4 - My recommendation for this is use an HTTP connector on a service task. To use the connector, in modeller configure the connector with url, method and payload. URL will typically be text, eg the url to call, method with typically be text, eg POST, payload can be your json payload. In the connector output variables, configure a script to parse the response. The name of the output variable will be the name of a process variable created by the connector. I usually use groovy script to parse the response and return a value for the connector’s output.

Heres a link to an example using the SOAP connector, REST is very similar [2]



Thanks a lot for your response, now things are a bit more clear for me.

  1. I have tried sending the JSON payload as type “Object” and I am able to see that in Camunda process instance using cockpit. Is it similar if the type is “json” too?

Can I still access using Spin?

Below is my request:
“orderPayload”:{“value”:“cust”:{“source”:“ORACLE_FIN_CLOUD”,“customerName”:“Tangible Media”,“partyNumber”:“1375”,“partyType”:“ORGANIZATION”,“partyStatus”:“A”,
“accountName”:“Tangible Media”,“accountNumber”:“36”,“customerType”:“DIRECT”},“type”:“Object”}}}

And in Camunda cockpit its showing as below:

  1. Here I am talking about the outbound service call using “Connector” component. I want to form another json and send it as part of the request.

I think, for this I can use Java delegates to form my json and then store it in the process context as a variable and use that as the inputParameter right?

Unable to deploy after using the “Connector” extension on tomcat camunda server.

Below is my BPMN process project:

How do I inject the comunda config file? and where?

And below is my Service Task