I am trying to call the Operate API from a BPMN in order to retrieve a process instance key.
The reason I’m doing this from a BPMN is that my client is trying to follow an all Connectors approach and have minimal custom code in a Java application.
My approach and problem:
- Use Operate’s Variable API (/v1/variables/search) to find the process instance key based on our custom request ID.
- In the Swagger UI, I can filter on variable value like:
{
"filter": {
"value": "\"TEST123\""
}
}
- If I try a similar filter using either the REST or Operate Connector, additional escape characters are added in front of my existing
\
. For example:
{"filter":{"value":"\\\"TEST123\\\""}
- This results in no records being found.
- I have tried dozens of different permutations to get this to work and have not had success.
- The reason we have to use a String for the Request ID is because the actual IDs are 19 digits long and if we put these in a process variable without converting to string, the value gets modified.
- I also have a need to filter on a JSON value like:
{
"filter": {
"value": "{\"highBits\": \"TEST123\", \"lowBits\": \"TEST345\"}"
}
}
My workaround for now is to use the Process Instance Search API, filter on ProcessId, and sort by most recent first. With that, I then call the Variable Search API and filter on processInstanceKey to confirm I’ve got the correct instance before proceeding.
My use case is retrieving statistics and sequence flows via the Operate API in order to facilitate nesting a live BPMN diagram with tokens in another UI.
I’ve read in other posts that there is no mechanism to for an instance to retrieve its own or other process instance keys and that we should instead use a custom identifier. Given that many of the API calls require a process instance key, it seems that we need to use this custom identifier to retrieve the process instance key. Is there an easier way to do this?