API Rest: Fetching Hsitory Task Variables

Hello,

I’m trying to fetch variables from history by taskId. I get always an empty raw.
If I fetch variables by processId, I get all the variables but with taskId as null.
I’m using “/task/{id}/complete” to submit variables and complete tasks.

Any help please.

Hello @Bilel_BARHOUMI and welcome,

Which rest endpoint do you use to fetch the variables?
Is it this one with query param taskIdIn:
https://docs.camunda.org/manual/7.11/reference/rest/history/variable-instance/get-variable-instance-query/
If it is not, please send us an example of your request.

Hi @Yana,

Yes, it this one.
My request is like this: http://localhost:3000/engine-rest/history/variable-instance?taskIdIn=dc18d615-b781-11e9-894c-0050568c7ff0

Thank you

I get this when I fetch all variables:
image

if this is the only variable which is returned the http://localhost:3000/engine-rest/history/variable-instance?taskIdIn=dc18d615-b781-11e9-894c-0050568c7ff0 response is empty as no variable is available with such task scope. The variable has a process instance scope as the taskId: null for it.

Thank you @Yana,

The http://localhost:3000/engine-rest/history/variable-instance?taskIdIn=dc18d615-b781-11e9-894c-0050568c7ff0 return all my variables that was submitted when completing tasks. But all of theme has the taskId null.

The question is, how can I attach variables to the task when I complete it?

How have you submitted the variables so far? Which API do you use, please give an example

I think this page might help you to understand better the concept of the variable scopes topic:
https://docs.camunda.org/manual/7.11/user-guide/process-engine/variables/#variable-scopes-and-variable-visibility

This is an example: