Unable to update task variables using REST API

Need urgent help !!

I tried retrieving task variables using REST API and was able to successfully get the output.

URL - http://localhost:8088/engine-rest/process-instance/4bdd2cad-e799-11ea-9cdc-0050568cd0c2/variables

Output -

{
“amount”: {
“type”: “Long”,
“value”: 1234,
“valueInfo”: {}
},
“item”: {
“type”: “String”,
“value”: “item”,
“valueInfo”: {}
}
}

But when I tried to update one of the variable for the same task I am getting error response as task doesn’t exist.

URL - http://localhost:8088/engine-rest/task/4bdd2cad-e799-11ea-9cdc-0050568cd0c2/variables

Input -

{
“modifications”: {
“amount”: {
“type”: “Long”,
“value”: 1234,
“valueInfo”: {}
}
}
}

Output -

{
“type”: “RestException”,
“message”: “Cannot modify variables for task 4bdd2cad-e799-11ea-9cdc-0050568cd0c2: task 4bdd2cad-e799-11ea-9cdc-0050568cd0c2 doesn’t exist: task is null”
}

Error logs -

Caused by: org.camunda.bpm.engine.exception.NullValueException: task 4bdd2cad-e799-11ea-9cdc-0050568cd0c2 doesn’t exist: task is null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:394)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:55)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:50)
at org.camunda.bpm.engine.impl.cmd.SetTaskVariablesCmd.getEntity(SetTaskVariablesCmd.java:54)
at org.camunda.bpm.engine.impl.cmd.SetTaskVariablesCmd.getEntity(SetTaskVariablesCmd.java:36)
at org.camunda.bpm.engine.impl.cmd.AbstractVariableCmd.execute(AbstractVariableCmd.java:53)
at org.camunda.bpm.engine.impl.cmd.AbstractPatchVariablesCmd.execute(AbstractPatchVariablesCmd.java:47)
at org.camunda.bpm.engine.impl.cmd.AbstractPatchVariablesCmd.execute(AbstractPatchVariablesCmd.java:30)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110)
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.TaskServiceImpl.updateVariables(TaskServiceImpl.java:322)
at org.camunda.bpm.engine.impl.TaskServiceImpl.updateVariables(TaskServiceImpl.java:317)
at org.camunda.bpm.engine.rest.sub.task.impl.TaskVariablesResource.updateVariableEntities(TaskVariablesResource.java:58)
at org.camunda.bpm.engine.rest.sub.impl.AbstractVariablesResource.modifyVariables(AbstractVariablesResource.java:249)
… 55 more

@amithsrinivasan seems you’re using process instance id as taskid to update the variables. Compare the endpoints.

Process: http://localhost:8088/engine-rest/process-instance/4bdd2cad-e799-11ea-9cdc-0050568cd0c2/variables

Task: http://localhost:8088/engine-rest/task/4bdd2cad-e799-11ea-9cdc-0050568cd0c2/variables

4bdd2cad-e799-11ea-9cdc-0050568cd0c2

4bdd2cad-e799-11ea-9cdc-0050568cd0c2

Thanks @aravindhrs ! I corrected and used right url. Now it is working.