Camunda Rest API - Start Process Instance With Payload

I’m using postman to start a process instance but have been unable to send a variable that is a List.

My payoad is

    	"pid":{"value":1, "type":"Long"},
    	"users":{"value":["big","abg"], "type":"object"}
    "businessKey" : "9u45"

Cannot instantiate process definition
Must provide ‘null’ or String value for value of SerializableValue type ‘Object’.

I tried a different approach:-
List users = Arrays.asList(new String[] {“u1”,“u2”});
ObjectValue typedObjectValue = Variables.objectValue(users).create();

So now my TypedValue is:-

ObjectValue [value=[u1, u2], isDeserialized=true, serializationDataFormat=null, objectTypeName=null, serializedValue=null]

Then i put this into the payload

   "users":{"value":"ObjectValue [value=[u1, u2], isDeserialized=true, serializationDataFormat=application/x-java-serialized-object, objectTypeName=null, serializedValue=null", "type":"object"}
   "businessKey" : "9u46"

Now, when i try starting my process, i get the following error

Cannot find serializer for value ‘ObjectValue [value=null, isDeserialized=false, serializationDataFormat=null, objectTypeName=null, serializedValue=153 chars]’."

I need some help to understand how to send a variable that’s a List.

I’ve read the documentation especially the section on process variables and serialization, but wasn’t able to put the pieces together (rubix cube syndrome).

Thanks for your help!

1 Like

@davekant did you load a custom object in camunda?

Looks like you are just trying to upload JSON. So change your type to json and you should be able to load your variable as a json object and use the SPIN library notation to access the properties and values.

Note that your json needs to be escaped JSON wrapped in a string.

Thanks Stephen.

I resolved the issue in the following way:
Send payload with value containing json with escaped the double quote, and type json.

"variables": {
	"users": {
		"value": "[\"big\",\"abg\"]", 

On the engine side,
List users = null;
// assume variableMap contains this field
Object usersList = variableMap.get(“users”);
if (usersList instanceof JacksonJsonNode) {
JacksonJsonNode node = (JacksonJsonNode) usersList;
users = node.mapTo(List.class);

Well, at least it works, although I’m sure there may be better approaches?

1 Like

As mentioned, you should be use the SPIN JSON mappers: