Camunda Rest - 获取已完成流程实例的变量

Camunda Rest - fetch variables of a completed process instance

我正在尝试构建审计跟踪并打印用户路径信息以完成任务 + 一些数据写入变量。

camunda Rest 有一些历史端点可以提供任务经过的每个“节点”。

但是我需要流程实例变量中的一些额外信息,但是当我尝试从已经完成的流程实例中获取变量时,API 回答“没有流程实例 id:xxxx 找到”

有没有办法读取已完成任务的变量中的信息?

提前致谢

流程实例完成后,其数据将从运行时表中删除,您用于 运行 实例的端点可以访问这些表。需要使用历史端点获取有关已完成流程实例的所有信息(底层 API 访问历史表)。 https://docs.camunda.org/manual/7.16/reference/rest/history/

此端点使用查询参数 processInstanceId 将 return 已完成实例的数据: https://docs.camunda.org/manual/7.16/reference/rest/history/variable-instance/get-variable-instance-query/

请求示例:

curl -X GET "http://localhost:8080/engine-rest/history/variable-instance?processInstanceId=5487fe88-72d2-11ec-b607-0242ac110002" -H  "accept: application/json"

示例响应:

[
  {
    "type": "String",
    "value": "GPFE-23232323",
    "valueInfo": {},
    "id": "54890ff9-72d2-11ec-b607-0242ac110002",
    "name": "invoiceNumber",
    "processDefinitionKey": "invoice",
    "processDefinitionId": "invoice:1:53c23d7a-72d2-11ec-b607-0242ac110002",
    "processInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "executionId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "activityInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "caseDefinitionKey": null,
    "caseDefinitionId": null,
    "caseInstanceId": null,
    "caseExecutionId": null,
    "taskId": null,
    "errorMessage": null,
    "tenantId": null,
    "state": "CREATED",
    "createTime": "2022-01-11T11:33:42.862+0000",
    "removalTime": null,
    "rootProcessInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002"
  },
  {
    "type": "String",
    "value": "Travel Expenses",
    "valueInfo": {},
    "id": "5489ac44-72d2-11ec-b607-0242ac110002",
    "name": "invoiceCategory",
    "processDefinitionKey": "invoice",
    "processDefinitionId": "invoice:1:53c23d7a-72d2-11ec-b607-0242ac110002",
    "processInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "executionId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "activityInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "caseDefinitionKey": null,
    "caseDefinitionId": null,
    "caseInstanceId": null,
    "caseExecutionId": null,
    "taskId": null,
    "errorMessage": null,
    "tenantId": null,
    "state": "CREATED",
    "createTime": "2022-01-11T11:33:42.865+0000",
    "removalTime": null,
    "rootProcessInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002"
  },
  {
    "type": "Object",
    "value": [
      "accounting",
      "sales"
    ],
    "valueInfo": {
      "objectTypeName": "java.util.ArrayList",
      "serializationDataFormat": "application/x-java-serialized-object"
    },
    "id": "54a6aa32-72d2-11ec-b607-0242ac110002",
    "name": "approverGroups",
    "processDefinitionKey": "invoice",
    "processDefinitionId": "invoice:1:53c23d7a-72d2-11ec-b607-0242ac110002",
    "processInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "executionId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "activityInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002",
    "caseDefinitionKey": null,
    "caseDefinitionId": null,
    "caseInstanceId": null,
    "caseExecutionId": null,
    "taskId": null,
    "errorMessage": null,
    "tenantId": null,
    "state": "CREATED",
    "createTime": "2022-01-11T11:33:43.055+0000",
    "removalTime": null,
    "rootProcessInstanceId": "5487fe88-72d2-11ec-b607-0242ac110002"
  }
]