cancel
Showing results for 
Search instead for 
Did you mean: 

REST API complete task with variable

sarkar92
Champ in-the-making
Champ in-the-making
I am trying to compete a task with a variable using REST API.

here is my xml

 <userTask id="usertask1" name="User Task" activiti:assignee="${assignee}">
        <extensionElements>
          <activiti:formProperty id="firstName" name="First Name" expression="${firstName}" writable="false"></activiti:formProperty>
          <activiti:formProperty id="lastName" name="Last Name" expression="${lastName}" writable="false"></activiti:formProperty>
          <activiti:formProperty id="groupName" name="Group Name" expression="${groupName}" writable="false"></activiti:formProperty>
          <activiti:formProperty id="decision" name="Do you approve the request ?" type="enum" required="true">
            <activiti:value id="true" name="Yes"></activiti:value>
            <activiti:value id="false" name="No"></activiti:value>
          </activiti:formProperty>
         
          <activiti:taskListener event="complete" class="net.simplyfiIT.workflow.EndListener"></activiti:taskListener>
        </extensionElements>
      </userTask>

I always pass dicision value as "true" but I get false.

I pass value like this

{"decision":true}


please help
8 REPLIES 8

trademak
Star Contributor
Star Contributor
Hi,

That looks like a correct way of completing the task. Do you see false in the complete Task listener?
Could you verify if the value is also false by just calling the REST API again to get the process instance details?

Best regards,

sarkar92
Champ in-the-making
Champ in-the-making
I see null in the complete the Task Listner.

In task listner i print the "dicision" value….It always print "null"

groopk
Champ in-the-making
Champ in-the-making
Try a string:

{"decision":"true"}

sarkar92
Champ in-the-making
Champ in-the-making
Try a string:

{"decision":"true"}


If I try like above it will give an classcastexception…..

frederikherema1
Star Contributor
Star Contributor
What REST-API-call are you using? I see you're using form-properties, but the rest-api currently only supports adding actual variables.

groopk
Champ in-the-making
Champ in-the-making
Try a string:

{"decision":"true"}


If I try like above it will give an classcastexception…..

The class cast exception is probably coming from wherever you are using the variable in your workflow.  Change that to expect a string- either using the value directly "true" or by turning it into a boolean/etc.

sarkar92
Champ in-the-making
Champ in-the-making
What REST-API-call are you using? I see you're using form-properties, but the rest-api currently only supports adding actual variables.


I'm using Complete Task through REST
by calling this

http://*******:6080/activiti-rest/service/task/{taskid}/complete
and pass this in body {"decision":true}

frederikherema1
Star Contributor
Star Contributor
What is the full stack trace of the class-cast exception you're getting? Also, is the variable you're trying to set already known in the process, before you try to set it using REST?