Unable to complete a task using REST-API

Hello there,

i tried a lot now but i can’t figure where the Problem is. I am trying to complete a Task using the REST-API by calling
restapi/task/' + filter.id + '/complete'

According to the documentation i need to send a response body like this:
data.variables.approved = {value: true};

But then i get the following error:
{ type: 'RestException', message: 'Cannot complete task f52862b2-3205-11e8-b4bd-0242ac120004: Unknown property used in express ion: ${S(data).prop("approved").boolValue() == true}. Cause: Cannot resolve identifier \'data\'' }

so i tried sending this:
data.variables.approved = true;

but then i get this error:
Can not construct instance of org.camunda.bpm.engine.rest.dto.VariableValueDto: no boolean /Boolean-argument constructor/factory method to deserialize from boolean value (true)\n at [Source: org .glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@6ebb5b3d; line: 1, column: 26] (through reference chain: org.camunda.bpm.engine.rest.dto.task.CompleteTaskDto["variables"] ->java.util.LinkedHashMap["approved"])

Thanks in advance,
Pascal

Hi Pascal,

you can find an example of the request body on the bottom of the documentation page [1].

It should look like this:

{"variables":
    {"approved": {"value": true}
}

Cheers,
Ben

[1] https://docs.camunda.org/manual/7.8/reference/rest/task/post-complete/#request

Hello Ben,

that is exactly what i am posting:

{ variables: 
    { approved: { value: true } } 
}

I dont use quotes in other posts, for example to start a process:

{ variables: { action: { value: 'addUser', type: 'String' },
        reason: { value: 'someReason', type: 'String' },
        validFrom: { value: '01.05.18', type: 'String' },
        validTo: { value: '01.05.18', type: 'String' } 
    } 
}

This works perfectly fine. But the approval always returns the error:

{ type: 'RestException',
  message: 'Cannot complete task XXXX: Unknown property used in expression: ${S(data).prop("approved").boolValue() == true}. Cause: Cannot resolve identifier \'data\'' }

Is it possible that something is wrong with the processDefinition?

Alright, so the POST request is going through correctly, but the exception is caused by a problem further down in your model, I assume it could be a gateway expression. You could share the model and we could see what’s wrong here.

Alternatively, just try ${approved} in your expression. There is no need to compare it to true since it’s a Boolean already.

1 Like

Allright, i have finally been able to talk to the guy who is administrating our camunda engine/processes. i have to send the data in a format that i did not know about and that we did not use somewhere else:

{ variables: { data: { value: JSON.stringify(valueAsJson), type: 'String' } } };

Now everything works fine!

thanks for the help :slight_smile:

2 Likes