Get all tasks for a particular process instance

How to get all the tasks, both completed and to be completed of a particular process instance through camunda REST API by inputting that particular instance id?

Any help would be appreciated.

Thanks
Alan

Hello Alan,

You can check REST docs and try it with processInstanceId query parameter.

Does this help you?

Best regards,
Yana

1 Like

Hi Yana
Yes. I tried with RESP API /history/task?processInstanceId=xxxxxxxxxxxx . But could not get all the tasks from that API for that particular instance. Also other APIs like /task gives only the current task. What i need is all the tasks which are completed and yet to be completed in that process instance.

Thanks
Alan

Hi Alan,

You need /history/task request in order to get all of the tasks (completed and not)
I tested it and it worked for me. Which camunda version do you use?
Make sure you provide existing processInstanceId.

Best regards,
Yana

1 Like

Hi @Yana,

I am facing the same issue. What I want is to get ALL tasks from a particular process.

Please find below my process:

When queried " /history/task" API, it is NOT returning Task 4 and Task5 in response, as it is yet to be executed. Is it the expected behavior?

How can get a list of all the tasks from the process beforehand?
Do I need to use Model APIs?

Thanks,
Shweta

Hi @Shweta,

you can query the history only for running or completed tasks.

If you want to get future tasks, you can only query for the process model (https://docs.camunda.org/manual/7.13/reference/rest/process-definition/get-xml/) and use the BPMN Model API (https://docs.camunda.org/manual/7.13/user-guide/model-api/bpmn-model-api/read-a-model/) to get them.

Hope this helps, Ingo

1 Like

Hi @Ingo_Richtsmeier

Thanks for your reply.

Are there any implications or known concerns while using this approach (something that I need to consider before-hand)?

Regards,
Shweta

You probably have to consider that, in general, you can’t know for sure what tasks will be executed. If the process model has forks you won’t be able (in general) to tell which path will be taken.