Cannot modify processInstance

Hello,

First of all I am still pretty new to camunda and was also not part of development/deployment of our applications.So please bear with my not so complete knowledge of camunda

I am trying to implement a way of modifying a processInstance into a tool but seem to be having some troubles.

Modifying a processInstance through the Camunda Cockpit seems to be working fine, but when trying to do so through Postman or through a Java Http Request I receive a 405 MethodNotAllowed
Here is the response I am getting in Postman:

I dont think the endpoint is the problem, because I can access other methods just fine(getting, deleting, creating a processInstance for example). Thats why I’m also not sure whether it might be an authorization issue since I’m guessing if it were I wouldn’t be able to do the other things.

I have also tried to use the JavaAPI ProcessEngine but I am experiencing similar problems.
Getting,deleting,creating Instances works but modifying them seems to be a problem yet again.
This is the exception I am getting in java

Exception in thread “main” org.camunda.bpm.engine.OptimisticLockingException: ENGINE-03005 Execution of ‘UPDATE PropertyEntity[next.dbid]’ failed. Entity was updated by another transaction concurrently.
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.concurrentUpdateDbEntityException(EnginePersistenceLogger.java:135)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.handleOptimisticLockingException(DbEntityManager.java:499)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.checkFlushResults(DbEntityManager.java:451)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:367)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:325)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:297)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:208)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:137)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:116)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.db.DbIdGenerator.getNewBlock(DbIdGenerator.java:49)
at org.camunda.bpm.engine.impl.db.DbIdGenerator.getNextId(DbIdGenerator.java:41)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.ensureHasId(DbEntityManager.java:688)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.insert(DbEntityManager.java:570)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionManager.insertExecution(ExecutionManager.java:46)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.insert(ExecutionEntity.java:1480)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.createNewExecution(ExecutionEntity.java:322)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.createExecution(ExecutionEntity.java:258)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.createExecution(ExecutionEntity.java:248)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.createExecution(ExecutionEntity.java:96)
at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.createConcurrentExecution(PvmExecutionImpl.java:497)
at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.executeActivitiesConcurrent(PvmExecutionImpl.java:830)
at org.camunda.bpm.engine.impl.cmd.AbstractInstantiationCmd.instantiateConcurrent(AbstractInstantiationCmd.java:342)
at org.camunda.bpm.engine.impl.cmd.AbstractInstantiationCmd.execute(AbstractInstantiationCmd.java:283)
at org.camunda.bpm.engine.impl.cmd.ActivityBeforeInstantiationCmd.execute(ActivityBeforeInstantiationCmd.java:63)
at org.camunda.bpm.engine.impl.cmd.ActivityBeforeInstantiationCmd.execute(ActivityBeforeInstantiationCmd.java:32)
at org.camunda.bpm.engine.impl.cmd.ModifyProcessInstanceCmd.execute(ModifyProcessInstanceCmd.java:80)
at org.camunda.bpm.engine.impl.cmd.ModifyProcessInstanceCmd.execute(ModifyProcessInstanceCmd.java:40)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:107)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl.execute(ProcessInstanceModificationBuilderImpl.java:251)
at org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl.execute(ProcessInstanceModificationBuilderImpl.java:242)
at camunda2.Camunda2.main(Camunda2.java:43)

I’m just taking a guess here since you did not include your request headers. The 405 error is thrown when you trying to access a POST endpoint with a GET request or any other request type which is not POST.

Thanks for your reply, but I am definitely using a POST request, tried through postman and through curl.

Also if the problem would just be using GET instead of POST then it should still work using the ProcessEngine right? But that also errors as described in my initial post

I can post my request headers later, though they dont really contain alot except application-type json since as far as I know there is no authorization setup, since the other endpoints also work without authorization

Well, you’re saying that

Modifying a processInstance through the Camunda Cockpit seems to be working fine

which is also using the REST-API of Camunda. Therefore this issue cannot be related to the API not functioning. And also the 405 error code is pretty clear in itself:

The 405 (Method Not Allowed) status code indicates that the method
received in the request-line is known by the origin server but not
supported by the target resource. The origin server MUST generate an
Allow header field in a 405 response containing a list of the target
resource’s currently supported methods.

Source: RFC 7231

So at least your postman request is failing due to a wrong method. Would it be about authorization, you would get a 401. So you should really double check your type of requests.

Hey thanks again for your time,

you are right about the 405 error code which is what makes the problem even weirder, because we are definitely sending POSTs. I have checked more than just two or three times.

The even weirder thing is that we just tried the exact same Request on another of our clusters(obviously we changed the url to the correct one) and there it worked just fine.

And again if it really were because of a wrong request method then atleast the Java ProcessEngine version would work, as you directly call a modification function, not specifying any request types, but as said before that also fails us.

Here is the curl that postman produces

curl -X POST \
http://OUR-URL/rest/process-instance/398cd972-ce53-8e73-0a58c0a8bc0d/modification \
-H \'Content-Type: application/json' \
-H 'Postman-Token: 6b254051-3dfa-4c3b-89fd-30c2f398264b' \
-H 'cache-control: no-cache' \
-d '{
"skipCustomListeners": true,
 "skipIoMappings": true,
 "instructions": [
   {
        "type": "startBeforeActivity",
        "activityId": "ServiceTask_1f391mo",
        "variables": {}
    },
    {
        "type": "cancel",
        "activityInstanceId": "Task_0ixe2v5:a4530f3a-e356-11e9-8b93-0a58c0a8af40"
    }
  ]
}'

As I said it worked perfectly fine when executed on another cluster so we started wondering if maybe our endpoint was wrong but then other REST calls wouldn’t work either and yet they do and we wouldn’t get a 405 anyways.

Another weird thing is as seen in the response headers of the initial post, the server also tells us that the OPTIONS method is also allowed, so for the sake of it we tried that aswell and yet we also get a 405 error code(maybe that request was wrong tho since I’m not even sure what the OPTIONS request method is even used for)