In terms of formatting the data in the response, you’re going to be limited to the format provided by the API (you can always create your own custom endpoints using the Java API, if you needed to).
In the meantime, working with what you have now… your ResponseBody
object may be redundant here as the REST API will give you access to UserId
and ContentId
individually without having to build that third object. For example, if you take the id of a process instance that has executed:
GET /history/variable-instance?processInstanceId=66562109-19f3-11eb-b1a7-0242ac150102
[
{
"type": "String",
"value": "admin",
"valueInfo": {},
"id": "6656210a-19f3-11eb-b1a7-0242ac150102",
"name": "UserId",
"processDefinitionKey": "Test__Content__GetContent",
"processDefinitionId": "Test__Content__GetContent:1:4fc7bed5-19f3-11eb-b1a7-0242ac150102",
"processInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102",
"executionId": "66562109-19f3-11eb-b1a7-0242ac150102",
"activityInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102",
"caseDefinitionKey": null,
"caseDefinitionId": null,
"caseInstanceId": null,
"caseExecutionId": null,
"taskId": null,
"errorMessage": null,
"tenantId": null,
"state": "CREATED",
"createTime": "2020-10-29T14:31:14.960+0000",
"removalTime": null,
"rootProcessInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102"
},
{
"type": "Long",
"value": 1234,
"valueInfo": {},
"id": "66573281-19f3-11eb-b1a7-0242ac150102",
"name": "ContentId",
"processDefinitionKey": "Test__Content__GetContent",
"processDefinitionId": "Test__Content__GetContent:1:4fc7bed5-19f3-11eb-b1a7-0242ac150102",
"processInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102",
"executionId": "66562109-19f3-11eb-b1a7-0242ac150102",
"activityInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102",
"caseDefinitionKey": null,
"caseDefinitionId": null,
"caseInstanceId": null,
"caseExecutionId": null,
"taskId": null,
"errorMessage": null,
"tenantId": null,
"state": "CREATED",
"createTime": "2020-10-29T14:31:14.967+0000",
"removalTime": null,
"rootProcessInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102"
}
]
It’s hard to say for sure without knowing more about your requirements, but if the json data suits your use case better, you could grab that variable by name:
GET /history/variable-instance?processInstanceId=66562109-19f3-11eb-b1a7-0242ac150102&variableName=ResponseBody
[
{
"type": "String",
"value": "\"{ \\\"UserId\\\": admin, \\\"ContentId\\\": 1234 }\"",
"valueInfo": {},
"id": "665780a4-19f3-11eb-b1a7-0242ac150102",
"name": "ResponseBody",
"processDefinitionKey": "Test__Content__GetContent",
"processDefinitionId": "Test__Content__GetContent:1:4fc7bed5-19f3-11eb-b1a7-0242ac150102",
"processInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102",
"executionId": "66562109-19f3-11eb-b1a7-0242ac150102",
"activityInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102",
"caseDefinitionKey": null,
"caseDefinitionId": null,
"caseInstanceId": null,
"caseExecutionId": null,
"taskId": null,
"errorMessage": null,
"tenantId": null,
"state": "CREATED",
"createTime": "2020-10-29T14:31:14.969+0000",
"removalTime": null,
"rootProcessInstanceId": "66562109-19f3-11eb-b1a7-0242ac150102"
}
]
At this point, you could take the string in response.data[0].value
and parse it into a json object that looks more like what you were looking for:
{
"ResponseBody": {
"UserId": "admin",
"ContentId": 1234
}
}