Hi there.
I am having trouble completing tasks through the rest API.
I have a multi instance subProcess, and inside there is a taskDefinition containing two task tokens for the same processInstance.
Now I wanted to complete those tasks from the outside world, so from my external app, I got the execution based on a variable I have inside the taskInstance, just so I complete the right taskInstance.
Then I can get the tasks based on the executionId (for some reason this extra step was needed, I would have preferred it if I could have gotten the task based on its variables right away, but for some reason I then get back both taskInstances)
const executionResponse = await request.get({
url: `${camundaApiUrl}/engine-rest/execution/`,
qs: {
variables: `uuid_eq_${uuid}`,
taskDefinitionKey: `${taskDefinitionKey}`
},
headers: {
'Content-Type': 'application/json',
},
json: true,
});
console.log('executionResponse', executionResponse);
const taskResponse = await request.get({
url: `${camundaApiUrl}/engine-rest/task/`,
qs: {
executionId: executionResponse[0].id,
taskDefinitionKey: `${taskDefinitionKey}`
},
headers: {
'Content-Type': 'application/json',
},
json: true,
});
So far so good. I got back the right task. Then I call the url to complete the task:
const response = await request.post({
url: `${camundaApiUrl}/engine-rest/task/${id}/complete`,
//url: `http://requestbin.fullcontact.com/16sbhbm1`,
headers: {
'Content-Type': 'application/json',
},
body: {
variables: inputVars
},
json: true,
resolveWithFullResponse: true
});
console.log('completeResponse', response.statusCode);
This also seems to work. I get back a 204 message and my app seems to have worked like a charm, but then I open the Camunda cockpit and I still see one of my two tokens there in the task. So for some reason it did not actually complete the task.
How can this be?