API to export and import Bot Lifecycle Management

Use the export and import bots APIs to customize the organization's Bot Lifecycle Management solution for an uninterrupted automation life-cycle.

Usually, the Control Room user has to depend on means other than Control Room (for example email) to deploy Task Bots from one environment to another. Using the Export-Import APIs, you can easily introduce a customized Bot Lifecycle Management solution thus removing all external factors that could possibly disrupt your automation life cycle.

As a Control Room user with Export bots and Download bots permission, you can export a bot and its dependent files. Similarly, as a user with Import bots and Upload bots permission, you can import that bot and its dependent files.

For example, you can move the bots that are verified as production ready from staging to production.

You can use the Control Room Export Import REST API to manage your automation Task Bots including dependent files in different environments such as Development, Testing, Acceptance, and Production based on your organization's automation needs.

Refer Export bots and Import bots articles to use the functionality from your Control Room user interface.

Features and benefits

  • Role based access control on Bot Lifecycle Management
  • Automatic export of dependencies (files and bots)
  • Audit and traceability on source and target environment for compliance
  • Email notification on successful execution or failure of export and import.

Export

  • The Control Room user whose credentials are used for authentication must have Export bots permission
  • The Control Room user whose credentials are used for authentication must have Download permission on the bots, minimum Execute permission on MetaBot, and dependencies that are being exported.
  • If version control is enabled in the source Control Room, the production version of all bots and dependencies which you want to export must be set.
  • User account that is used to run the Control Room services must have access to the location where package is getting exported, for example, network location(shared drive) or on Control Room server machine.

Import

  • The Control Room user whose credentials are used for authentication must have Import bots permission
  • The Control Room user whose credentials are used for authentication must have Upload permission on the bots and dependencies that are being imported.
  • The Control Room user who will execute the utility to import multiple bots must have access to the exported package file provided by Automation Anywhere.

API Endpoints

  • Export- <your_control_room_url>/v1/blm/export

    For example,https://crdevenv.com:81/v1/blm/export

  • Import- <your_control_room_url>/v1/blm/import

    For example, https://crtestenv.com:82/v1/blm/import

Using the above end points of the Bot Lifecycle Management Export Import API you can export and import a single bot and all of its dependencies.

Export Bot

Export a single bot with its dependent files using the Export API provided by Automation Anywhere:

  1. Use the POST method to generate a token using the end point http(s)://<hostname:port>/v1/authentication. For this provide the Control Room instance as Server Name /Hostname /IP and the Port number.

    For example, https://crdevenv.com:81/v1/authentication

  2. Use the Post method and state the parameters for credentials in Body Data. Refer sample:
    {
    "username":"cradmin",
    "password":"cr@admin"
    }
  3. Click Execute.
  4. Bot Lifecycle Management Export API will make use of the authentication token that is obtained using the Authentication API. The authentication token has to be passed on as one of the header inputs to the Bot Lifecycle Management Export API.
  5. Use the POST method and URL: <your_control_room_url>/v1/blm/export.

    Provide the following parameter for the request header:

    • packageName: Name of the package to be created.
    • selectedFileIds: This is a numeric value. Enter one or more IDs of the parent bots that you want to export.
    • fileIds: This is a numeric value. Enter one or more IDs of the dependency bots that you want to export.
    • excludeMetabots: This is a Boolean value. Enter either true or false. Enter true if the dependent MetaBots are to be excluded in package
    • password: This is a string and is optional. Enter the export password.
      For example:
      {
        "packageName": "doc-test",
        "selectedFileIds": [12
        ],
        "fileIds": [
          12
        ],
        "excludeMetaBots": true,
        "password": ""
      }
  6. Click Execute.
  7. If you are testing the API in Swagger, the Response body returns a download link that can be used to download the exported file in aapkg format. Otherwise, you must save the Response body as a binary file in aapkg format.

Import Bot

After the bot is successfully exported to a network drive or Control Room machine path, another authorized user can import that package to a different Control Room using the Import API:

  1. Use the Post method to generate a token using the end point http(s)://<hostname:port>/v1/authentication. Provide the Control Room instance as Server Name /Hostname /IP and the Port number.

    For example, https://crtestenv.com:82/v1/authentication

  2. Use the Post method and state the parameters for credentials in Body Data.

    For example:

     { 
    "username":"cradmin2", 
    "password":"cr@admin" 
    }
  3. Click Execute.
  4. Bot Lifecycle Management Import API will make use of the authentication token that is obtained using the Authentication API. The authentication token has to be passed on as one of the header inputs to the Bot Lifecycle Management Import API.
  5. Use the POST method and URL: <your_control_room_url>/v1/blm/import.

    Provide the following parameter for the request header:

    • file: Choose the file that you want to import in your Control Room.
    • overwriteOption: Select either the skip, overwrite, or abort option if the file you are importing already exists.
    • productionversionOption: Select either the current or imported option. Set the production version as imported with the package or keep the current version as is.
    • Password: Enter the password to import protected package. You must not keep this field empty otherwise keep the default value as the password

    For example:

    Request Body:
    "file": "doc-test_6488adfd-5989-46d8-a38a-7009876f2612.aapkg"
    "overwriteOption": "skip"
    "productionVersionOption": "current"
    "password": "********"
  6. Click Execute
  7. The bot is imported in your Control Room.

    For example: Because the file already exists in the folder, it is skipped as per the overWrite parameter value is defined as skip.

    Response body:

    {
      "alreadyExistFiles": [
        "Automation Anywhere\\My Tasks\\Task_C.atmx"
      ],
      "checkoutFiles": [],
      "filesHasNoPermission": [],
      "addedOrUpdatedFiles": [],
      "overwrittenFiles": [],
      "skippedFiles": [
        "Automation Anywhere\\My Tasks\\Task_C.atmx"
      ]
    }

API Response Codes

Http(s) Status code Response- Description Corrective Action
200 Package created successfully NA
400 Bad request parameter Retry with valid parameters
404 File not found Ensure that the file/bot is present in Control Room
501 Permission error Ensure that you have the Export/Import bots or Upload/Download permission