How can we tell if a task has been completed (using /task/{id}/complete)?

I understand that I can get a list of “finished” tasks using the /history/task endpoint (GET and/or POST) but that does not seem to differentiate between tasks that are finished because POST /task/{id}/complete has been called and via some other means. We specifically need to know only the tasks that have been completed using the complete endpoint. How can we do that ?

You can define some variable and flag it in the post request.
https://docs.camunda.org/manual/7.16/reference/rest/task/post-complete/

Tasks that are already completed have an end time that is different than null.

The history API will get you all the completed tasks so far and the ones currently pending.

You can differentiate between them by checking the endTime field.

If it has an endTime different than null, it has already been completed.

Hi @hgilliam_quilhealth,

If I understand you correctly, your need is to differentiate tasks completed successfully from ones cancelled or ended by any other means.

Below REST endpoint might be of help to you.

https://docs.camunda.org/manual/7.15/reference/rest/history/user-operation-log/get-user-operation-log-query/

You can query for log entries with operationType of Complete and entityType of Task.

By the way… all of the results from the history endpoint have an endTime, even those that finished for reasons other than the /task/{id}/complete endpoint.

So… we tried the /history/user-operation endpoint using the operationType and entityType filters: operationType=Complete entityType=Task and that returned zero results.

We then tried just entityType=Task and only got 4 results where the operationType was Delete. We have thousands of processes each with in the order of 10 tasks. So we were surprised to get so few results and none with the operationType=Complete

We did a number of tests where we completed tasks in a workflow (called /task/{id}/complete) and also ended them by other means. We followed how the data changed in the ACT_RU_TASK, ACT_HI_TASKINST and ACT_HI_ACTINST tables and believe that the DELETE_REASON_ column of the ACT_HI_TASKINST gives us the information we need. This seems to also be returned by the /history/task endpoint as the deleteReason field. When deleteReason === “completed” then we know that task had the /task/{id}/complete called for it.