User Task not found on Complete in Zeebe

Hi, im trying to complete a userTask from my spring application. I’m running Zeebe 8.7 and connect to it using zeebe-client-java 8.7.

My task exists, i can see it in optimize:

{
	"flowNodeType": "USER_TASK",
	"flowNodeId": "OP00XT001_Sample_Task",
	"startDate": "2025-06-11 11:45:45",
	"eventId": "2251799813686192_2251799813686196",
	"jobType": "io.camunda.zeebe:userTask",
	"jobRetries": 1,
	"jobWorker": "",
	"jobCustomHeaders": {},
	"variables": {},
	"candidateGroups": [],
	"candidateUsers": [],
	"endDate": null,
	"jobDeadline": null,
	"incidentErrorType": null,
	"incidentErrorMessage": null,
	"flowNodeInstanceKey": "2251799813686196"
}

Now i want to coplete it through my custom app:

    @PostMapping(value = "/task/{taskId}/complete")
    public void completeTask(@PathVariable("taskId") Long jobKey) throws ExecutionException, InterruptedException {

        zeebeClient.newUserTaskCompleteCommand(jobKey)
                .variables(Map.of())
                .send().get(); 

        System.out.println("Task " + jobKey + " completed.");
    }

However it seems like the engine can not find this task to complete:

io.camunda.zeebe.client.api.command.ProblemException: Failed with code 404: 'Not Found'. Details: 'class ProblemDetail {
    type: about:blank
    title: NOT_FOUND
    status: 404
    detail: Command 'COMPLETE' rejected with code 'NOT_FOUND': Expected to complete user task with key '2251799813686196', but no such user task was found
    instance: /v2/user-tasks/2251799813686196/completion
}'

This makes no sens for me, as i can clearly see the user task in the operate.

I know the library is properly configured, as i can start and interact with the process through it, the only missing piece is to complete user tasks. Any ideas why is that?

I think you’re using the wrong task id.
Can you find the task using the rest API Search tasks | Camunda 8 Docs and confirm the id?

Regards,
Alex

This link is for Tasklist api, im not using Tasklist at all. I want to communicate directly with zeebe and send this complete command to zeebe.

I’m not suggesting you use Tasklist API, but confirm the task ID for investigation purposes.

Regards,
Alex

Basically, I think you need to use something like the following:

zeebeClient
    .newUserTaskCompleteCommand(userTaskId)
    .variables(Map.of())
    .send()
    .get();

And you need to know userTaskId(jobKey is not a task id).

ok, i see, is there any way i can get this userTaskId without deploying Tasklist? We really do not need tasklist :laughing:
It seems to be kind of stupid to deploy a separate app just to get userTaskId

Sure, you can use ZeebeClientImpl - zeebe-client-java 8.7.5 javadoc and search for a task

for example:

client.newUserTaskSearchRequest()
            .filter(filter -> filter.candidateUser("demo"))
            .send()
            .join()

ok, then there are two topics in this:

  1. i have deployed tasklist api and got the taskId:
{
  "id" : "2251799813686200",
  "name" : "Sample Task 2",
  "taskDefinitionId" : "OP00XT001_Sample_Task",
  "processName" : "OP00X_SAMPLE_PROCESS",
  "creationDate" : "2025-06-11T09:45:45.818+0000",
  "completionDate" : null,
  "assignee" : "demo",
  "taskState" : "CREATED",
  "sortValues" : [ "1749635145818", "2251799813686200" ],
  "isFirst" : true,
  "formKey" : null,
  "formId" : null,
  "formVersion" : null,
  "isFormEmbedded" : false,
  "processDefinitionKey" : "2251799813685289",
  "processInstanceKey" : "2251799813686192",
  "tenantId" : "<default>",
  "dueDate" : null,
  "followUpDate" : null,
  "candidateGroups" : null,
  "candidateUsers" : null,
  "variables" : [ ],
  "context" : null,
  "implementation" : "JOB_WORKER",
  "priority" : 50
}

Now i see the ID: ‘2251799813686200’ is indeed different than flownodeInstance key, howeevr when i try to complete the task using the newly found id, i still get the same issue:

{
    "type": "about:blank",
    "title": "NOT_FOUND",
    "status": 404,
    "detail": "Command 'COMPLETE' rejected with code 'NOT_FOUND': Expected to complete user task with key '2251799813686200', but no such user task was found",
    "instance": "/v2/user-tasks/2251799813686200/completion"
}
  1. the search for user tasks seems to be experimetal and is either not enabled or not working properly, any request to search api results in:
io.camunda.zeebe.client.api.command.ProblemException: Failed with code 405: 'Method Not Allowed'. Details: 'class ProblemDetail {
    type: about:blank
    title: Unexpected server response
    status: 500
    detail: {"timestamp":"2025-06-11T13:32:59.093+00:00","status":405,"error":"Method Not Allowed","path":"/v2/user-tasks/search"}
    instance: null
}'

i believe the code you posed is from 8.8 alpha library, correct?

That is correct, I missed that you’re using 8.7, not 8.8.
But it’s weird why you still can’t complete a task when you’re using a proper task id.

What if you check your BPMN file and update it to Camunda user task?

Then redeploy it and try to complete.

this works! Thanks a lot! As for the querying of the tasks from zeebe java library, this still says

405,"error":"Method Not Allowed"

do i need to enable this method somehow on the side of zeebe since its experimental api?

Yes, it should be enabled depending on your deployment type. Here are some details Overview | Camunda 8 Docs

1 Like

thanks a lot!