I am using Camunda 8 self-managed with version 8.7.8
And I tried to use this API from the Operate Search variables for process instances | Camunda 8 Docs to search for variable using process instance key and the variable name and I was expecting it to return one result for the variable, but I found it return multiple results for the same variable in the response and the latest value exists at the end
So why multiple values are returned for the same variable
and when I tried to sort the list returned by key DESC I got this error 403 in postman
As for multiple values, I would need more information to answer. Can you share a response you are getting with multiple values, as well as what is being reported in Operate? Does Operate show the same data?
In this workflow I just created variable statusCode with value 123 and I modified the value in the script task to 456 then to 789 then to 147 so I expected from the endpoint to give me the latest value only
@Mohamed_Ahmed_Mohame - this is expected. Camunda logs changes to every variable, which is critical for providing a meaningful and useful audit log and process history. When you have the top (global) history item selected in Operate, it is showing you the “current” or “final” state of the global variables in the process, but if you click on each activity it should show the changes to the value of statusCode over time. The API is searching for variables with the name “statusCode”, of which several values exist in the process data.
The variable scope key is the element instance key if the element spawns a new variable scope (i.e. in case it can have input or output mappings). Otherwise, it is the flow scope key
In your case it should be the flow scope key as no new variable scopes were introduced