Creating transient-variable for given process-instance through POST fails

When i’m setting (creating) transient-variable by POST /execution/{id}/localVariables of execution ( everything is OK.
But when i want to set transient-variable to ‘global’ execution by POST /process-instance/{id}/variables (, it doesn’t work!
While not-transient works as expected.

Why it can be so? Is it a bug or is there any reason?
Appreciate your answers.

can you elaborate on “doesn’t work”
is there an error in the log?
Is the call unsuccessful?

1 Like

@Niall, no, there is no errors in log and response status is success (204). But new transient variable wasn’t be created - i check it with GET /process-instance/{id}/variables.

If variable is not transient - it will be created.

Hi @raliev,

That’s how transient variables work: They are not persisted, so they are only available in the context of the API call you submit them with. Check for details.


Hello, @thorben.
Yes, i know that transient variables are not persisting to DB and live only in memory till first transaction boundary. But before this ‘fatal’ transaction, they are alive and, of course, can be fetched by GET /process-instance/{id}/variables - such it works if i create this var for execution with POST /execution/{id}/localVariables ( where id is execution of current task in this process instance)

Why can it be so? It seems that its bug.

Hi @raliev,

I think you have a misunderstanding about transaction handling in Camunda. Every API call coresponds to one transaction, regardless if it advances the process or not. Things that are not persisted do not live longer than the duration of the API call. Transaction boundaries in the process only control how much of the process is executed within a transaction that triggers continuation (e.g. user task completion, job execution). Using the set variables API is pretty much unrelated to that.


1 Like

Thanks for reply, @thorben.
But so how this can be true (you can test it by yourself):

And if it can’t behave in such a way - why documentation offers to include information about variable is transient or not? :slightly_smiling_face:

Can anyone say, please, why via POST /execution/{id}/localVariables transient variable can be created (and saved to execution, can be fetched by GET and visible in cockpit), but with POST /process-instance/{id}/variables it doesn’t appear in process instance execution?

I can’t reproduce this and this would be incorrect. Please post the exact steps for reproduction (requests with request bodies).