Unable to modify process variable using REST API

We’re using the REST interface for external tasks, though we’ll likely switch to the embedded engine. However, I think we discovered a bug in the REST interface (7.15). Our workflow has a state variable that gets passed to services, and several of them modify the variable and send the new value back to the engine in the “complete” API. However, the variable value is never changed in the engine. With some experimentation, we found that if we use a different variable name, it will show up in the engine. However, if the process variable already exists, the engine ignores the update. The log is empty and there are no errors anywhere. It just ignores the attempt to change the value. I wrote a very simple REST service that just implements FetchAndLock and Complete, which takes a variable named Count, increments it, and sends it back. The BPMN just calls this is a loop. The variable never changes. The console trace below shows the JSON requests and responses. Anyone have any idea what’s going on?


Perhaps try adding the
"withVariablesInReturn": true
clause to your POST message, as described in the REST Doc

I wonder if it has to do with using strings to hold your count variable.

Thank you, GotnOGuts. Good ideas! I made both changes you suggested, adding the type and the “withVariablesInReturn”. Unfortunately, I still get the same result. The variable is still not changed.

I used a string because in our workflow it’s a string. I just did the increment to change it.

It has to be something I’m doing wrong, but I’m really running out of ideas.

Hello @HalE ,

when the process engine is waiting at the task, which scope the variable is in? You can inspect this in the Variable view of the process instance in the cockpit.

If the scope is local, consider exporting the result value after modifying it so it lives in the parent scope.

I hope this helps


1 Like

Hi Jonathan,

I know there are local and global process variables, but I have not set any of them to local. I wondered if this was an issue. This is what the cockpit shows:

Just to make sure I didn’t muck up the BPMN, this is what it looks like:

1 Like

Hi @HalE ,

thank you for checking back so fast! The behaviour you saw is intended: When modifying a variable, the engine will find the variable by name in the lowest (task) scope and change this value. By exporting the variable afterwards, you will overwrite the value in the parent scope.

This should work :slight_smile:


I always forget to ask what’s set on the Input/Output parameters setting.

As @jonathan.lukas suggests, if you put the Count variable in the Output parameter it should work.