@MrDeeb Camunda provides the Tasklist REST API in self-managed setups starting in recent versions. Here’s how you can use it to complete user tasks using REST:
1. Enable Tasklist REST API
In self-managed Camunda 8, the REST API is experimental. Make sure it’s enabled in your application.yaml or environment config.
Example config:
camunda.tasklist.rest-enabled: true
Or as an env variable:
CAMUNDA_TASKLIST_REST_ENABLED=true
2. REST Endpoint to Complete a Task
Once enabled, you can use:
POST /tasklist/v1/tasks/{taskId}/complete
Request Body:
{
"variables": {
"approval": "yes"
}
}
3. Java Example Using REST (with OkHttp)
import okhttp3.*;
public class CompleteUserTask {
public static void main(String[] args) throws Exception {
String taskId = "YOUR_TASK_ID"; // Replace with actual task ID
String url = "http://localhost:8080/tasklist/v1/tasks/" + taskId + "/complete";
String bearerToken = "YOUR_AUTH_TOKEN"; // If authentication is enabled
String jsonBody = "{ \"variables\": { \"approval\": \"yes\" } }";
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(
jsonBody,
MediaType.parse("application/json")
);
Request.Builder requestBuilder = new Request.Builder()
.url(url)
.post(body)
.addHeader("Content-Type", "application/json");
if (!bearerToken.isEmpty()) {
requestBuilder.addHeader("Authorization", "Bearer " + bearerToken);
}
try (Response response = client.newCall(requestBuilder.build()).execute()) {
if (response.isSuccessful()) {
System.out.println("Task completed successfully.");
} else {
System.err.println("Error completing task: " + response.code() + " - " + response.body().string());
}
}
}
}
4. Get Tasks via REST
You can list tasks assigned to a user or available with this endpoint:
GET /tasklist/v1/tasks
Optional query params: state=CREATED, taskDefinitionId, processInstanceId, assignee, etc.
5. Authentication Note
If you’re using Camunda Identity, you’ll need to:
• Authenticate via Keycloak
• Use the OAuth Bearer token in your request headers