Start process instance with a json variable

I see that the process config has JsonObjectRestVariableConverter registered, is that all it needs or an additional config is required? After the process is created, the variable named customer is being set as null but I expect a json node

Here is a sample post request to start the process instance.

curl --location 'localhost:8080/process-api/runtime/process-instances' \
--header 'Content-Type: application/json' \
--data '{
    "processDefinitionKey": "saveOrder",
    "businessKey": "dummy",
    "returnVariables": true,
    "transientVariables ": [
        {
            "name": "customer",
            "type": "json",
            "value": {
                "name": "kermit",
                "age": 30,
                "address": {
                    "city": "New York"
                }
            }
        }
    ]
}'

What do you mean the variable is set as null? From what I can see you are using transientVariable, which means that the customer variable is only available in the transaction, after the the transaction ends the variable will no longer be available, i.e. the variable is not stored in the database.

Cheers,
Filip

I have tried both variables and transientVariables but it doesn’t set it in execution context. When I try to retrieve it back it’s returned as null

Looks like RestVariable inside ProcessInstanceCreateRequest for a json variable is being mapped to LinkedHashMap instead of JsonNode, thats what is causing variable to be set as null. This must be fixed.

As a workaround, I had to create a custom controller to do that conversion and then start the process using runtime service.

Hey @deepakkapoor23,

This is working correctly. Have a look at the test case. If something is not working for you, then please provide a test case showing what isn’t working.

Cheers,
Filip

ProcessInstanceResource doesn’t even have the create method I am using so I don’t know what this just is testing. I will write a test when I get a chance. It’s not high priority for me anymore since I worked around it already.

The test is for the ProcessInstanceCollectionResource, not the ProcessInstanceResource. Those are 2 different classes that have different endpoints. The ProcessInstanceCollectionResource does contain the method you are calling.

Cheers,
Filip

You are right, ProcessInstanceCollectionResource is the one I am hitting. But I think the problem is this:

// When the variable is coming from the REST API it automatically gets converted to an ArrayList or
// LinkedHashMap. In all other cases JSON is saved as ArrayNode or ObjectNode. For consistency the
// variable is converted to such an object here.

Somehow its not reaching this path and not converting the Map variable to a JsonNode

Hey @deepakkapoor23,

I really don’t know what more I can tell you. I’ve shown you a test where sending the exact same structure works as expected. Therefore, I would ask you to share a test case displaying the problem you are seeing, without that there is not more that we can do.

Cheers,
Filip

I will write a test when I get a chance…thanks for your help on this.