Problem Determining If Process Instance was Cancelled

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:

DELETE engine-rest/process-instance/fe6e83f9-99fd-11e6-bbca-0242ac120003

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?

Hi @Stephen_Bucholtz,

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).

Cheers,
Roman

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?

Yes.

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.

Cheers,
Roman

@roman.smirnov is there a way to inject the user id without enabling authentication?

In the Java-API it’s

identityService().setAuthenticatedUserId("theUserId");

Cheers, Ingo

1 Like