Question / Use Case
I'm trying to "recreate" an inflight instance state in another environment (BPMoC for instance).
Is there an API available in IBM BAW that allows you to update all process variables that could help me?
Answer
Yes, starting IBM BAW 19003 and later such an API has been added but as it turned out it's not working as documented and per IBM such API is only supported under the playback in WebPD and should not be included in the Knowledge Center (KC).
The API endpoint is -
PUT /rest/bpm/wle/v1/process/<Process-instance-id>/allVariables
IBM will likely remove its documentation from KC. So, in this article I'd like to explain how you can use this REST API in PC/PS if you need to recreate an instance.
DISCLAIMER: This exact method is not supported by IBM (I do not understand why), so, please use it at your own risk. I can just add that I have used it successfully at one of the migration projects to recreate instances this way and it worked fine in all lower env's and in PROD.
Prerequisites:
Obtain the correct IDs for the process / linked process, so that to use it in JSON parameter.
Example -
(BPMREST-UI below is a REST tool available in IBM BAW - https://host:port/bpmrest-ui)
BPMREST-UI > IBM BAW REST API > Process API > Exposed Processes
BPD ID = 25.7f86f794-3789-4b79-add1-d25a9216b080
SnapShot ID = 2064.f48d0687-171f-4e0e-8247-3085b2a2efa2
Branch ID = 2063.ad107838-eb84-454c-8123-3ed0f896b7bc
BPMREST-UI > IBM BAW REST API > Other > Retrieve Process Applications
ProcessApp ID = 2066.c9a94a1c-54ad-42a2-9a48-7d444e1a3621
BPMREST-UI > IBM BAW REST API > Process API > Retrieve Models
Use previously gathered parameters (BPDID, SnapshotID, BranchID, ProcessAppID) to obtain the linked process ID / external ID:
name:"MyLInkedProcess",
type:"activity",
activityType:"subBpd",
externalID:"25.17f3c778-2034-4fa4-975b-465c383ea8f2"
...
tokenID:null,
taskID:null,
ID:"4b34e2d3-e678-4e52-b3cc-87124e42d8fd"
Calling the main REST API:
At this stage you should be ready to call our main "allVariables" REST API -
BPMREST-UI > IBM BAW REST API > Process API > Update Instance All Variables
/* JSON to update two variables: linked_process_variable and my_other_linked_process_variable
{
"variables":{"linked_process_variable":"123","my_other_linked_process_variable":"123"},
"contexts":{"4b34e2d3-e678-4e52-b3cc-87124e42d8fd":
{
"processId":"25.17f3c778-2034-4fa4-975b-465c383ea8f2",
"variables":["linked_process_variable","my_other_linked_process_variable"]
}
}
}
/* JSON to update one single variable: e.g. linked_process_variable
{
"variables":{"linked_process_variable":"updated value"},
"contexts":{"4b34e2d3-e678-4e52-b3cc-87124e42d8fd":
{
"processId":"25.17f3c778-2034-4fa4-975b-465c383ea8f2",
"variables":["linked_process_variable","linked_process_variable","linked_process_variable"]
}
}
}
The method returns one of the following status codes:
200 OK - The request was successfully completed.
400 Bad Request - The instanceId parameter is missing or not valid, or the body of the request is not a JSON object or does not comply to the schema of the business object.
401 Unauthorized - The caller is not authorized for this request.
404 Not Found - The instanceId does not exist on server.
406 Not Acceptable - The requested content type or content encoding is not supported.
409 Conflict - The status of the business process definition (BPD) instance is not Active, Suspended or Failed. You can use this API only to update variables of an active, suspended, or failed BPD instance.
415 Unsupported Media Type - The content type or content encoding of the request is not supported.
500 Internal Server Error - A severe problem has occurred. Check server logs.
Comments
0 comments
Please sign in to leave a comment.