Not able to fetch JSON variable's value via REST API


#1

Hi, I am facing some weird issue, I have a test object which is of type JSON, when I start the process with the object I am able to see the data in the cockpit, but when I try fetching the variable using GET /task/{id}/variable/test or GET /process-engine/variables, I am getting the following result instead of the value.

{
    "test": {
        "type": "Json",
        "value": {
            "nodeType": "OBJECT",
            "value": false,
            "dataFormatName": "application/json",
            "number": false,
            "object": true,
            "boolean": false,
            "string": false,
            "array": false,
            "null": false
        },
        "valueInfo": {}
    }

Any Idea what I may be doing wrong?


#2

Hi, Anyone has any idea about this? I found that the variable data was stored in ACT_GE_BYTEARRAY instead of ACT_RU_VARIABLE.


#3

Hi @thorben, Do you have any idea about this issue?


#4

#5

Hi @Yana, So should this affect the response of rest api call to fetch that variable?

Normally a variable fetch would return the value of that variable, this one just returns the above details in case of a JSON object.


#6

Please read the documentation at https://docs.camunda.org/manual/7.9/reference/rest/process-instance/variables/get-variables/ carefully. The parameter deserializeValues (default value true) means this:

If set to true, a serializable variable will be deserialized on server side and transformed to JSON using Jackson’s POJO/bean property introspection feature.

So when you fetch variables this way, the engine reads your variable as a Spin JsonValue Java object and throws this into Jackson, which results in the JSON that is returned, but that is not meaningful to you. To access the actual JSON value, set deserializeValues to false.

Cheers,
Thorben


#7

Thanks @thorben :slight_smile: