Installing workflow projects to an offline server by calling REST APIs
You can call REST APIs to export versions of workflow projects and then install them to
an offline server.
Before you begin
Procedure
Complete the following steps:
- If you don't already have an API key for the Business Automation Studio server and for the offline workflow server you are installing on, you must create one. You need these keys to authenticate with Business Automation Studio. For the instructions to generate an API key, see Generating API keys for authentication.
- Construct an authorization header that contains your encoded API key by following the instructions in Authorizing HTTP requests by using the Zen API key. To save space, in the examples here, we'll assume that the variable $ACCESS_TOKEN_HEADER is set to Authorization: ZenApiKey api_key_encoded_value, where api_key_encoded_value is the encoded value that is obtained for the appropriate server. Each API call requires this header.
-
Construct a BPMCSRFToken parameter for the Business Automation Studio server and for the offline
workflow server using POST/system/login to obtain it. Each subsequent API call
requires this header, for example:
curl -X POST -H "${ACCESS_TOKEN_HEADER}" -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"refresh_groups": true, "requested_lifetime": 7200}' 'https://zen-front-door-hostname/instance_prefix/ops/system/login'The URL might be, for example:https://cpd-cp4ba.apps.cp4ba-ca.55baw.p1.openshiftapps.com/baw-bawins1/ops/system/loginYou will get a response such as this:
{"expiration":7200,"csrf_token":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NDI2MTA2NjcsInN1YiI6ImNwNGFkbWluIn0.8742sRV3CTHN_fY45W-29_CrqeuOqRlFWPFItCKnodI"}The response has a csrf_token value that you can set as the parameter value. We'll assume that the variable $CSRF_TOKEN_HEADER is set to BPMCSRFToken: <csrf_token_value> for the respective server.
- On the Business Automation Studio
server, create the installation package by using POST
/std/bpm/containers/{container}/versions/{version}/offline_package. Ensure you are using
the ACCESS_TOKEN_HEADER and CSRF_TOKEN_HEADER for the Business Automation Studio server, for example
curl -X POST -H "$ACCESS_TOKEN_HEADER" -H "$CSRF_TOKEN_HEADER" -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://zen-front-door-hostname/instance_prefix/ops/std/bpm/containers/PA1/versions/1/offline_package?server=OffLn1'You will get a response such as this:
{"description":"Your request to create and install an offline package from the specified snapshot on the specified server was submitted. You can check the progress of the operation by calling the returned url.","url":"https://zen-front-door-hostname/instance_prefix/ops/system/queue/7?key=8b09658ae4fdb42ccfe33a20122265f4"} - Check the status using the URL that was returned in the previous step using GET
/system/queue/{id}, for example
curl -X GET -H "$ACCESS_TOKEN_HEADER" -H "$CSRF_TOKEN_HEADER" -H 'Accept: application/json' 'https://zen-front-door-hostname/instance_prefix/ops/system/queue/7?key=8b09658ae4fdb42ccfe33a20122265f4'You will get a response such as this:
{"state":"success","result":{"container":"PA1","server":"OffLn1","version":"SN03"},"last_modified":"2022-01-18T22:11:25.367Z"} - Export the installation package using GET
/std/bpm/containers/{container}/versions/{version}/install_package, for example
curl -X GET -H "$ACCESS_TOKEN_HEADER" -H "$CSRF_TOKEN_HEADER" -H 'Accept: application/octet-stream' 'https://zen-front-door-hostname/instance_prefix/ops/std/bpm/containers/PA1/versions/1/install_package?server=OffLn1' -o /c/MyExportPkg.zipNote the location and name of the file you exported.
- On the offline workflow server, install the application version that you just exported
using POST /std/bpm/containers/install. Ensure you are using the
ACCESS_TOKEN_HEADER and CSRF_TOKEN_HEADER for the offline server, for example
curl -X POST -H "$ACCESS_TOKEN_HEADER" -H "$CSRF_TOKEN_HEADER" -H 'Content-Type: multipart/form-data' -H 'Accept: application/json' -F 'install_file=@C:\MyFiles\PA1 - 1.zip' {"type":"formData"}' 'https://zen-front-door-hostname/instance_prefix/ops/std/bpm/containers/install?inactive=false&caseOverwrite=false'You will get a response such as this:
{"description":"Your request to import the specified file was submitted. You can check the progress of the import in the system log or by calling the returned url.","url":"https://zen-front-door-hostname/instance_prefix/ops/system/queue/9?key=d2772760f7bd30006e877164ba8a6ee9"} - As described in step 5, you can check the status using the URL in the response, for
example
curl -X GET -H "$ACCESS_TOKEN_HEADER" -H "$CSRF_TOKEN_HEADER" -H 'Accept: application/json' 'https://zen-front-door-hostname/instance_prefix/ops/system/queue/9?key=d2772760f7bd30006e877164ba8a6ee9'You will get a response such as this:
{"state":"success","result":{"details":""},"last_modified":"2022-01-19T14:46:16.979Z"}Your project is now installed on the offline server.