View Task Variables after Completed Task

Can I view Task variables via rest after I have completed the task?

Hi @TommyK100
I guess Get Variable Instance | docs.camunda.org should help you.

Great! But when running
history/variable-instance/" + TaskID + “”

I get an error response

{“type”:“InvalidRequestException”,“message”:“Historic variable instance with Id ‘366e790f-4227-11ec-be20-0242ac110002’ does not exist.”}

According to documentation, you have to provide the id of the variable instance, not the TaksID.
image

How shall I get the variable id, when all I have the ProcessInstanceID?

You can use Get Historic Details | docs.camunda.org and search by processInstanceId.
Part of the response is
image

1 Like

Hi @TommyK100,

Using below REST API resource you can query for historic variable instances that fulfill the given parameters including variable name and process instance Id.

https://docs.camunda.org/manual/7.15/reference/rest/history/variable-instance/get-variable-instance-query/

Thanks!
I got “history/detail?processInstanceId=” + processInstanceID + “”
to work.

1 Like

Hi, sorry that I’m writing in this old topic. My process contains a user task. After the task is completed, it can be that the process is not finished and a new user task is created again, something like a loop. I’m completing the user task with a variable (taskService.complete(taskId, Variables.createVariables().putValue(STIPULATION_CONTROL_MODEL, stipulationControlModel)); ) but I can’t find any way to get the version of the variable associated with each user task, just the last version of it, also, the variable associated with the process itself.
Am I doing something wrong? Or is it not possible what I want to do? I found a work around like creating a different variable each time the user task is completed, but it would be great if it can be done out of the box.
Work around:
taskService.complete(taskId, Variables.createVariables().putValue(STIPULATION_CONTROL_MODEL, stipulationControlModel).putValue(STIPULATION_CONTROL_MODEL + “_” + taskId, stipulationControlModel));

Thanks in advance!