Hi,
I want to complete a user task in its task listener. For this purpose, I am simply getting the id of the task in its task listener and then call a rest API to complete the task.
Although the task id is correct, I encounter the following error when calling the rest API:
“org.camunda.bpm.engine.rest.exception.RestException: Cannot complete task <task-id>: Cannot find task with id <task-id>: task is null”
My code is shown below:
@Override
public void notify(DelegateTask delegateTask) {
var taskId = delegateTask.getId();
try {
completeUserTask(taskId);
} catch (Exception e) {
System.out.println(e.getStackTrace());
throw new RuntimeException(e);
}
}
private void completeUserTask(String taskId) throws IOException, InterruptedException {
var completeUserTaskRequest = HttpRequest.newBuilder(URI.create(baseUrl + "/task/" + taskId + "/complete"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(""))
.build();
var completeUserTaskResponse = HttpClient.newHttpClient().send(completeUserTaskRequest, HttpResponse.BodyHandlers.ofString());
System.out.println(completeUserTaskResponse);
}
And this is my task listener:
Could anyone guide me what the problem could be?
I appreciate any help.