We are having a problem using the REST API to determine if a process instance was cancelled.
We are using Camunda v7.5.0, in a Standalone configuration, with Apache Tomcat.
In order to determine if a Process Instance was cancelled, we are using this REST API endpoint:
GET engine-rest/history/user-operation?processInstanceId=<id>&entityType=ProcessInstance&operationType=Delete
When we use the Camunda cockpit to cancel a running process instance, the above query correctly returns an operation indicating the instance was cancelled.
However, when we call the following REST API endpoint directly from our application, the query above does not return an operation indicating the instance was cancelled:
Note, in our application, we are not creating user’s within Camunda so we don’t have any logged-in/authenticated users when using the REST API.
I wonder, since we are calling the DELETE process-instance endpoint without an authenticated user, if this why there is not an entry in the user-operation list for the cancel operation?
If this is true, we need to know how to determine if a process instance has been cancelled in our situation. Is there some other REST API endpoint we can call to determine if a process instance has been cancelled?
The cancel operation is only logged when the operation is performed in the context of a logged in user (see 1). If you want to write the operation log regardless of a logged in user, then you can set the process engine configuration restrictUserOperationLogToAuthenticatedUsers to false (see 2).
Thank you for the quick response. We will try setting restrictUserOperationLogToAuthenticatedUsers to false.
I assume that if we do this, when we call the REST API to Delete a process instance, since we will not have a logged in user, that the userId field obtained from the operation log will be null. Is this correct?
If this is correct, is there any way to supply our own user id when deleting a process instance so that the log will contain the user id we supply?
You have to authenticate the corresponding user, so that its user id is used in the user operation log. In case of the REST API you can configure the authentication as described in 1.