cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving all tasks defined in a process definition via REST API

dvk78
Champ in-the-making
Champ in-the-making
I was trying to find out if it was possible to retrieve the list of all User tasks configured in a process definition/instance via the REST API.
From the user guide I could not determine if that is possible at all. Only the tasks that have been completed/current seem to be getting returned for runtime/tasks or runtime/executions.
I would like to know if it is possible via the REST API to retrieve all tasks in a process definition/instance.
15 REPLIES 15

balsarori
Champ on-the-rise
Champ on-the-rise
I am not sure whether you want to retrieve task instances or task definitions (User Tasks defined in a process definition).

If you are referring to task instances, you can retrieve task instances of a specific process instance or process definition, check 15.8.12. Get historic task instances section in the Activiti User Guide
http://activiti.org/userguide/index.html

Use the processInstanceId parameter to get task instances of a specific process instance. Use the processDefinitionId parameter to get task instances of all process instances of a specific process definition. There are other parameters that you can use to filter results as needed.


If you are referring to task definitions, I don't think that is currently possible. However, you can retrieve the whole process definition (which will include all user tasks definitions) using

GET repository/process-definitions/{processDefinitionId}/model

dvk78
Champ in-the-making
Champ in-the-making
Thanks for responding balsarori.
For my situation, it would be ideal if I could retrieve all the 'User Tasks' that are defined in a process definition. If that is not possible, the alternative would be to retrieve all the 'User Tasks' that could be potentially associated to the process instance as per the process definition.
I guess it would boil down to API support that would involve parsing the bpmn xml and listing all the 'User Tasks' defined in it. If that support is not there, may be it could be built for a future release?

jbarrez
Star Contributor
Star Contributor
> l if I could retrieve all the 'User Tasks' that are defined in a process definition

Then you need to filter on process definition (id or key)

dvk78
Champ in-the-making
Champ in-the-making
I do not see any Task-related data in the REST response for a GET of a process-definition. Which API are you referring to?

balsarori
Champ on-the-rise
Champ on-the-rise
Check 15.3.5. Get a process definition BPMN model section in the user guide. Did you do a GET call to the following REST url?

repository/process-definitions/{processDefinitionId}/model

dvk78
Champ in-the-making
Champ in-the-making
Thanks. This works. I had tried repository/process-definitions/{processDefinitionId} . Missed the /model at the end.

arunk
Champ in-the-making
Champ in-the-making
How can we identify the tasks in the list is a user task(not a gateway or mail task etc,.)

amruta_holey
Champ in-the-making
Champ in-the-making
I am trying to fetch all tasks having specific processDefinitionId.
This is my url:
http://localhost:8080/activiti-rest/service/runtime/tasks?size=100000&processDefinitionId=reviewSale...
But tasks are not getting filtered by processDefinitionId. it giving me all tasks from ACT_RU_TASK table without filteration.
How to resolve this ?

amruta_holey
Champ in-the-making
Champ in-the-making
It is giving correct result when I filter it by processInstanceId but giving all task records from the table when I pass processDefinitionId as a url parameter