Send processInstanceId with HTTP-connector service task

I have an http-connector in a service task which calls an external rest service, and I am able to build a json request with process variables collected by previous tasks, as in:

  "someId": "${someId}"

Now I want to send not only process variables, but also the processInstanceId. This fails, obviously the processInstanceId is not visible to the expression language as a variable:

  "someId": "${someId}",
  "processInstanceId": "${processInstanceId}"

How can I send the processInstanceId with http-connector, without using a JavaDelegate?

Where are you executing this? Where is the creation occurring? You should be able to use a script such as Js to build your json. You would do something like execution.getProcessInstanceId()

I have defined the request body in Camunda Modeler:

Excellent. What instances are available (like execution as you mention) is documented in Variables Available During Script Execution. Instead of Type=Text I can switch to Script and enter a script which builds a JSON string. Thank you!

@dschulten take a look at to get you started.

You can improve upon the Javascript usage.

If you want some more power take a look at: Replacing Http-Connector with Jsoup usage

1 Like