How to complete a User Task and add a boolean property using REST end point

I know how to complete a User task. I use the below REST end point on local system to complete a task instance

http://localhost:8080/engine-rest/task/<task_id>/complete

I send an empty payload. I want to send some payload; simple key-value pairs and then use it in XOR.
Actually, my plan is to use a User task for the Approval process and I will get a value for a boolean value suppose “approved” and then I will use it in the XOR gate to decide to which branch should be called.

I am trying to set this value in the payload when completing the User Task

{
“approved”: true
}

And then using #{approved} and #{not approved} Expressions for branching the decision.

I am not able to get the property set.

What is the correct way to set a boolean or any property for a User task while completing the task and only through REST API?

The docs have some good examples that you can take a look at.

In this case to set a variable the payload needs to look like this:


{"variables":
    {"aVariable": {"value": "aStringValue"},
    "anotherVariable": {"value": 42},
    "aThirdVariable": {"value": true}}
}
1 Like

I have just used similar payload, but I am adding the type of variable in the JSON like below:

{
  "variables": {
    "approved": {"value":true,"type":"boolean"}
  }
}

Is that not required? Can I just send boolean value without type?

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

Looks like I have got the above payload reference from some older version of Camunda.

I’m pretty sure both would be accepted

Yes, both are accepted, but the one without data type is better for the use case.