I am using Camunda Platform 7.19.0. I am trying to set an Object variable from Task list or from the REST API. For example, when I try to create an ArrayList variable from like this
PUT /process-instance/aProcessInstanceId/variables/aVarName
{
"value" : "[1,2]",
"type" : "Object",
"valueInfo" : {
"objectTypeName": "java.util.ArrayList",
"serializationDataFormat": "application/xml"
}
}
I get this error in cockpit
I also tried to set it in Tasklist like this but I am not sure what to type here
I have already added camunda-engine-plugin-spin in Gradle dependencies. I have checked the documentation about serialization/deserialization, but I am still confused about how to set Object variables.
Any help would be appreciated.
Thanks.
@cambarantama Refer this page:
Does the object type name have to be a POJO? I am trying something like an ArrayList like this
{
"value" : "[\"item1\", \"item2\", \"item3\"]",
"type" : "Object",
"valueInfo" : {
"objectTypeName": "java.util.ArrayList",
"serializationDataFormat": "application/json"
}
but it deserialization keeps failing.
From the docs: To retrieve the serialized form of a variable, use the deserializeValues=false GET parameter.
@cambarantama , In previous example you’ve used xml as serializationDataFormat and the below example you’re using JSON.
Which serializationDataFormat you’re actually looking for?
Here are the supported variable types:
@ aravindhrs
I am looking for serializationDataFormat of type application/json.
I was attempting to set a variable such as this
{
"value" : "[\"item1\", \"item2\", \"item3\"]",
"type" : "Object",
"valueInfo" : {
"objectTypeName": "java.util.ArrayList",
"serializationDataFormat": "application/json"
}
Basically, how can I set a variable of type Object either from Tasklist or the REST API without using a predefined POJO?
Hi @cambarantama
Try the following
{
"value": ["item1", "item2", "item3"],
"type": "Object",
"valueInfo": {
"objectTypeName": "java.util.ArrayList",
"serializationDataFormat": "application/json"
}
}
Hi @hassang
With that, I get this error:
{"type":"InvalidRequestException","message":"Cannot put process instance variable myArrayList: Must provide 'null' or String value for value of SerializableValue type 'Object'.","code":null}