cancel
Showing results for 
Search instead for 
Did you mean: 

Create/Update a complex object process variable using RESTful

yisa
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to use this REST api runtime/process-instances/{processInstanceId}/variables/{variableName} to create (and update later) a process variable that's an object. The object is something like the following:

{"id": 1,  "name": "testName", "externalData": {"id": 2, "name": "String"}}

I'm having a hard time to figure out what to pass in the value field as the input to the REST api. Stringify the above object into JSON didn't help. I got 415 error. If I set the variable type to serializable, how is it possible to pass raw byte array of my data object to a REST api?

According to the topic at http://forums.activiti.org/content/passing-complex-objects-instantiate-process

"This is currently not possible. In the new REST-api, this will be possible because there is a pluggable mechanism for variable-types. It will allow you to plug is some code to create a POJO based on a JSON-representation (exposed as a Map). This will be available in 5.13 of 5.14."

I'm using 5.15, so I'm assuming it's possible now. I would appreciate if someone could point me to some examples of storing a complex object as variable through REST api and have the variable be accessible within the workflow.

4 REPLIES 4

yisa
Champ in-the-making
Champ in-the-making
Anyone can help me? Please let me know if I need to clarify the question.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Create/update serializable variable through REST API is supported. Have a look on the following jUnit test in activiti source
org.activiti.rest.service.api.runtime.ProcessInstanceVariablesCollectionResourceTest#testCreateSingleSerializableProcessVariable
Regards
Martin

yisa
Champ in-the-making
Champ in-the-making
Thanks for the reply! The test code gave me some ideas, but the problem is I'm calling the REST api from an angularjs client, not from Java. I'm assuming I have 2 options:
1. find a way to call restful from angular with content-type application/octet-stream
2. I'm still interested in finding an example to do the following:
"In the new REST-api, this will be possible because there is a pluggable mechanism for variable-types. It will allow you to plug is some code to create a POJO based on a JSON-representation (exposed as a Map). This will be available in 5.13 of 5.14."

Any suggestions is much appreciated!

jbarrez
Star Contributor
Star Contributor
Well, the example above is that mechanism. You need a system on the server side that knows how to handle the json you posted to the server …