Get task list with process variables

This is question has been asked two years ago. How to use Camunda Engine Java API to get list of tasks with process variables?

We can use API to get list of tasks. But to get process variable associated, we have to make additional call for each task. It is just too much hit on performance.

Any updates on Camunda API in recent two years regarding this issue?

I think you can achive this with 2 rest-api-calls and some pre- and post-processing. Firstly get the list of tasks you are interested in as you already do. Secondly call the post method “variable-instance” with a list of process-instance-id’s for which you want to know the variables . The body for the rest-call is eg
“processInstanceIdIn”: [ “processInstanceId1”, “processInstanceId2”, …]

The result contains all variables for the specified process instances. Postprocess the result and assign variables to the tasks via processInstandId.
This should be much faster due to only 2 api-calls.

Hi @hanscrg,

the Camunda Tasklists use filter queries for this. This feature lacks documentation, but if you inspect the REST calls from the Tasklist with the Developer console, you should get an idea how to do this with the Java API as well.

Hope this helps, Ingo