cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with a text variable with multiple values set using REST

marco_altieri
Star Contributor
Star Contributor

I am using the following rest call to start a new process:

POST /api/enterprise/process-instances
curl 'http://localhost:9080/activiti-app/api/enterprise/process-instances' -H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary $'{"values": {"customId": "222471", "comment": "comment", "financeGroup": "2015", "assignees": ["2018", "2013"]}, "processDefinitionId": "Review:34:57801","businessKey": null, "outcome":"Started", "name": "Review 222471"}' --compressed

 I can see that the process is started and two tasks are assigned, as expected, to the groups "2018", "2013".

The only problem is that the json returned by the API call does not have  a value for the property "assignees".

In the list of variables returned, I can see the following snippet:

{"name":"assignees","type":"serializable","value":null},

{"name":"financeGroup","type":"string","value":"2015"}

It seems that, because "assignees" has multiple values, it is returned as null.

Is this expected?

I am using "Alfresco Process Services" version 1.8.1.

4 REPLIES 4

hari
Star Contributor
Star Contributor

I think Assignees will hold the user(s) to whom the task was assigned to. In your case, the task was with the group which I think was the reason for it being null. 

salaboy
Star Collaborator
Star Collaborator

What type is "assignees": ["2018", "2013"] ? defined in your process variables? 

I can see that is marked as serializable.. but you probably want to define it as an String[] or a list of strings. 

Hi Mauricio,

the type of the variable assignees was "text". 

It works well if I pass only one value. It doesn't work only when I pass an array.

Thanks

Marco

cjose
Elite Collaborator
Elite Collaborator

Serialized data is not returned by this API involving forms! If you set the property rest.variables.allow.serializable=true, you can use the core engine API and get the link to the variable in response. eg:

Request

curl 'http://localhost:8080/activiti-app/api/runtime/process-instances?tenantId=tenant_1' -H 'Authorization: Basic YWRtaW5AYXBwLmFjdGl2aXRpLmNvbTphZG1pbg==' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary $'{"variables": [{ "name": "assignees", "value": ["2018", "2013"]}],"processDefinitionId":"serialize:2:132549", "returnVariables":true}' --compressed

Response

{"id":"132616","url":"http://localhost:8080/activiti-app/api/runtime/process-instances/132616","businessKey":null,"suspended":false,"ended":false,"processDefinitionId":"serialize:2:132549","processDefinitionUrl":"http://localhost:8080/activiti-app/api/repository/process-definitions/serialize:2:132549","processDefinitionKey":"serialize","activityId":"sid-11AC2671-8E15-45AF-9103-E6EC6D7F6865","variables":[{"name":"initiator","type":"string","value":"1","scope":"local"},{"name":"assignees","type":"serializable","value":null,"valueUrl":"http://localhost:8080/activiti-app/api/runtime/process-instances/132616/variables/assignees/data","scope":"local"}],"tenantId":"tenant_1","name":null,"completed":false}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍