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


#1

Hello.
When i’m setting (creating) transient-variable by POST /execution/{id}/localVariables of execution (https://docs.camunda.org/manual/7.10/reference/rest/execution/local-variables/post-local-variables/) everything is OK.
But when i want to set transient-variable to ‘global’ execution by POST /process-instance/{id}/variables (https://docs.camunda.org/manual/7.10/reference/rest/process-instance/variables/post-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.


#2

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


#3

@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.


#4

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 https://docs.camunda.org/manual/7.10/user-guide/process-engine/variables/#transient-variables for details.

Cheers,
Thorben


#5

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.


#6

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.

Cheers,
Thorben


#8

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:


#9

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?


#10

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

Thanks,
Thorben