How get variable form values using REST API


I model a form Field, like:
<camunda:formField id=“variable1” type=“string” />

I would like to get the values saved using RESP API.

For example: I save a value in variable1 (Using Tasklist) and I tried to get values using form-variables.

But, I could not access the value saved.

Is it possible to fetch values from saved form variables ? How ?

If you want to access the value of a specific variable for a given process instance you can use this call.

Hi Nial,

It was not work.
When I try to access variables, (eg: /process-instance/{id}/variables/{varName}) it return an empty list {} or [].

In the Camunda Modeler, I only create form fields in form data (Form tab).
Should I do other steps to makes form fields a visible variable ?

Variable values will, in general, only be available if explicitly set in you process or passed in when the process is started.

I am no expert, and others may correct me, but if your “form” isn’t stored in a process variable, then there is no way to retrieve it using the REST API. If your form is stored in a process variable, but the value you want is embedded within a document, you will either need to extract it inside the process and set process variable with its value (execution.setVariable(“formValue”, “This is the value I want”)), or you will have to consume the document at the client and parse it out yourself.

As I stated, I may be wrong about where “form” data might reside, but the only way your going to get a value from your process using the REST API call you mentioned is to explicitly set it. This can be done either in the BPMN itself, a script associated with the BPMN, or in a separate Java class. The method for setting and retrieving process variables varies depending upon which of the preceding you’re using, but they generally involve some form of the “execution.setVariable” or “execution.getVariable” function. In Java you do this through the Java delegate.

After some tests, I could access the variables using /get-variable API REST. The difference now is I can access after Complete the task, not only save. Anyway, it is enough for me now.


1 Like

HI Carlo,

Can you show the API REST that you are using to get the variables from form-camunda in the Tasklist?

I start a Task using API REST with defaults values.

In the form-Camunda, in TaskList, I can see it. Then I edit the form and Save. When I try to retreive the variables, It shows the default values from the begining, not the updated values.



Hi @vathanakkeu,

Sorry for my delay.

I did not solve this situation that you save and retrieve the updated variable value, as you describe. In fact, I did not implement “Save” funcionality in my application and not investigate it in deep.
I don´t know if it is a bug or a expected behavior.

Anyway, I access the variable data in a Python script as above:

def get_process_variables(process_id):

url = 'http://localhost:8080/engine-rest/engine/default/variable-instance?deserializeValues=false&processInstanceIdIn={}'.format(process_id)
r = requests.get(url)
variables= r.json()

return variables 

To access variables in the Data Form, I use:
def get_form_variables(task_id):

url = 'http://localhost:8080/engine-rest/engine/default/task/{0}/form-variables'.format(task_id)
r = requests.get(url)
variables = r.json()

return variables 

And, for case variables:
def get_case_variable(case_id, variable_name = “”):

query_parameters = "&caseInstanceIdIn={}".format(case_id)

if variable_name != "":
    query_parameters = query_parameters + "&variableName={}".format(variable_name)

url = 'http://localhost:8080/engine-rest/engine/default/variable-instance?deserializeValues=false{}'.format(query_parameters)
r = requests.get(url)
variables= r.json()

return variables

Hi Carlo,

Thank for taking the time to response!