REST API: retrieve case variables

Hi,
I write a method to retrieve case variables. it works pretty well except when I complete the task.

  1. I create a simpe process with an human task
  2. via rest api I start the task
  3. if I call “/API/bpm/caseVariable?p=0&c=10&f=case_id%3d”+case_id I get all the variables with ‘null’ values
  4. via bonita portal I complete the task setting values to variables (mapped with form inputs)
  5. if I call “/API/bpm/caseVariable?p=0&c=10&f=case_id%3d”+case_id I get:

HTTP STATUS: 500 {“exception”:“class org.bonitasoft.web.toolkit.client.common.exception.api.APIException”,“message”:“Error when getting case variables”,“cause”:{“exception”:“class org.bonitasoft.engine.exception.RetrieveException”,“message”:“USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceNotFoundException: Process instance with id \u003c5008\u003e not found”},“api”:“bpm”,“resource”:“caseVariable”}

what do I do wrong?
thanks in advice
Claudio

Hi,

Yes, this is the normal behavior. When the case is completed, its state changed to “Archived”. Therefore, a different set of APIs has to be used to retrieve the information.

Unfortunately, the current REST Api doesn’t provide an endpoint to retrieve the variables of an archived case. There is several possibility to work around this.

First, if you store your data in the BDM instead of process variables, you’ll still be able to retrieve them after the case completion.

Second option is to use, the community project called REST Api context. It provides an endpoint to retrieve the variables for archived cases.

Third option is to build your own rest api endpoint. It’s not straightforward with the Community Edition, but it’s doable. More info here .

Cheers