cancel
Showing results for 
Search instead for 
Did you mean: 

Populating Process Variables using REST

vprince
Champ in-the-making
Champ in-the-making
I am starting a new process instance using http://localhost:8080/activiti-app/api/enterprise/process-instances with POST body

{
  "processDefinitionId": "test1:30:80205",
  "name": "testName:30:80205",
  "values": {
    "name": "Test Name",
    "id": "This should be stored in a variable"
  }
}

Using the modeler, I create a process instance variable called 'id'. I also created a text box called 'name' in a start-form. When the workflow is started, I see that the 'name' is populated but the variable 'id' is not.

How do you populate a process instance variable when you start a workflow using REST?

Vijay
2 REPLIES 2

abbask
Champ on-the-rise
Champ on-the-rise
The "value" element in your json should only contain the values to be given to the start form of your process. that's why only name is getting populated as it is a textbox in your "START-FORM". process-variables cannot be initialized like this. have a look at the developer's guide - https://docs.alfresco.com/activiti/docs/dev-guide/1.5.0/#_start_process_instance

cjose
Elite Collaborator
Elite Collaborator
If you would like to initialize variables as part of your process instance start, add the following to your json request

"variables": [
  {"name":"id",
   "value":"This should be stored in a variable",
   "type":"string"
  }]

Your request would look like
<javascript>
{
"processDefinitionId": "test1:30:80205",
"name": "testName:30:80205",
"values": {
  "name": "Test Name"
},
"variables": [{
  "name": "id",
  "value": "This should be stored in a variable",
  "type": "string"
}]
}
</javascript>