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

Before you export projects
  • Ensure you have Read permission or are a repository administrator. For more information, see Granting access to the repository.
  • Obtain a set of service credentials (functional ID and password) from your account administrator. Use these service credentials for authenticating REST API calls to the Business Automation Studio sever and the offline workflow server.

Procedure

Complete the following steps:

  1. Construct an authorization header containing your service credentials with the following format: Authorization: functional_id encoded_value_of_password.

    To save space, in the examples here, we'll assume that the $ACCESS_TOKEN_HEADER variable is set to the value of the service credentials. Each API call requires this header.

  2. Construct a BPMCSRFToken parameter for the Business Automation Studio sever and for the offline workflow server using POST/system/login to obtain it. Each subsequent API call requires this header.
    For example, for the Business Automation Studio sever
    curl -X POST -H "${ACCESS_TOKEN_HEADER}" -H 'Content-Type: application/json' -H 'Accept: 
    application/json' -d '{"refresh_groups": true, "requested_lifetime": 7200}'
    'https://bas-dev-tenant-hostname/ops/system/login'
    and for the offline workflow server
    curl -X POST -H "${ACCESS_TOKEN_HEADER}" -H 'Content-Type: application/json' -H 'Accept: 
    application/json' -d '{"refresh_groups": true, "requested_lifetime": 7200}'
    'https://baw-awsins1-run-tenant-hostname/ops/system/login'

    You 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 $CSRF_TOKEN_HEADER variable is set to BPMCSRFToken: csrf_token_value for the respective server.

  3. 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://bas-dev-tenant-hostname/ops/std/bpm/containers/PA1/versions/1/offline_package?server=OffLn1'
  4. 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://bas-dev-tenant-hostname/ops/system/queue/7?key=8b09658ae4fdb42ccfe33a20122265f4'</p>

    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"}
  5. 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://bas-dev-tenant-hostname/ops/std/bpm/containers/PA1/versions/1/install_package?server=OffLn1' 
    -o /c/MyExportPkg.zip

    Note the location and name of the file you exported.

  6. 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' 
    'https://baw-awsins1-run-tenant-hostname/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://baw-awsins1-run-tenant-hostname/ops/system/queue/9?key=d2772760f7bd30006e877164ba8a6ee9"}
  7. 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://baw-awsins1-run-tenant-hostname/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.

What to do next

For detailed information on each operation, see Operations REST APIs.

For more guidance, see Calling external REST services.