KB Article #181407

RESTAPI-v2.0: Configure a scheduler for an Advanced Routing Subscription

Problem

Assume you have configured a Subscription to an Advanced Routing instance, and now you would like to add a Transfer Site to pull files from a remote server, based on schedule. Using the below steps you can configure this with the help of the ST's REST API version 2.0.

Resolution

In all commands below, the following placeholders and default values are used:


  • ST_ADMIN_ACCOUNT:ST_ADMIN_PASS: The credentials (username:password) of a Master Administrator for ST, for example admin:admin.
  • ST_SERVER_ADDRESS:ST_ADMIN_PORT:The SecureTransport server's IP or hostname and the port for the admin service (default is 444 for root instances and 8444 for non-root instances). For example: 10.10.10.10:444.
  • SUBS_ID: The ID of the Subscription that will be updated.
  • SUBS_FOLDER: The Subscription folder.
  • ST_ACCOUNT: The ST Account that holds the Subscription.
  • SUBS_APPLICATION_NAME: The Advanced Routing Application name.
  • TRASNFER_SITE_NAME: The name of the Transfer Site that will be used to pull the files.
  • TRANSFER_CONF_ID: The ID of the Transfer Configuration, attached to the Subscription.
  • START_DATE: The start date of schedule in UNIX timestamp (epoch) with milliseconds. For example 1703919600000.
  • EXEC_TIME: The execution times. For example 09:00.


All placeholders must be replaced with the appropriate values, so we recommend that you copy the commands in a text editor and review and edit them before use.


The steps below use the command line tool curl to execute the API calls. If you are using another API client, the confguration of the API calls should be reworked for that client.



Step 1

First, we need to add a Transfer Site to the Subscription, which will be used to pull the files. The equivalent action from Admin UI is to select a Transfer Site from the drop-down menu in the Subscription's configuration. If you already have selected a Transfer Site in the Subscription, you can skip this step.


The JSON body:


{
    "folder": "/SUBS_FOLDER",
    "account": "ST_ACCOUNT",
    "application": "SUBS_APPLICATION_NAME",
    "type": "AdvancedRouting",
    "transferConfigurations": [
    {
        "site": "TRASNFER_SITE_NAME",
        "tag": "PARTNER-IN",
        "outbound": false,
        "dataTransformations": []
    }]
}


The curl query:


curl -k -u ST_ADMIN_ACCOUNT:ST_ADMIN_PASS -X PUT "https://ST_SERVER_ADDRESS:ST_ADMIN_PORT/api/v2.0/subscriptions/SUBS_ID" -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"folder\":\"/SUBS_FOLDER\",\"account\":\"ST_ACCOUNT\",\"application\":\"SUBS_APPLICATION_NAME\",\"type\":\"AdvancedRouting\",\"transferConfigurations\":[{\"site\":\"TRASNFER_SITE_NAME\",\"tag\":\"PARTNER-IN\",\"outbound\":false,\"dataTransformations\":[]}]}"



Step 2

Next, we need to get the ID of the Transfer Configuration of the Subscription (note that this is not the ID of the Transfer Site):


The curl query:


curl -k -u ST_ADMIN_ACCOUNT:ST_ADMIN_PASS -X GET "https://ST_SERVER_ADDRESS:ST_ADMIN_PORT/api/v2.0/subscriptions/SUBS_ID" -H  "accept: application/json"


The output is:


{
    "type": "AdvancedRouting",
    "id": "SUBS_ID",
    "folder": "/SUBS_FOLDER",
    "account": "ST_ACCOUNT",
    "application": "SUBS_APPLICATION_NAME",
    "maxParallelSitPulls": null,
    "flowAttrsMergeMode": null,
    "folderMonitorScheduleCheck": null,
    "flowName": null,
    "scheduledFolderMonitor": null,
    "flowAttributes": {},
    "schedules": [],
    "transferConfigurations": [
    {
        "id": "TRANSFER_CONF_ID",
        "site": "TRASNFER_SITE_NAME",
        "tag": "PARTNER-IN",
        "outbound": false,
        "dataTransformations": [],
        "transferProfile": null
    }],
    .....
    .....
}


Note the "id": "TRANSFER_CONF_ID" member of the transferConfigurations object in the response. We need to collect this value and use it in later API calls. Also note that the schedules object is empty at this point. We'll populate it in the next step.



Step 3

To configure the scheduler we need to update the Subscription and pass the TRANSFER_CONF_ID from the previous step, and a properly configured schedules object. The below JSON body shows both these with example values. Refer the ST's Swagger page and drill down to the respective examples for information about the various scheduler options you can use.



Open the subscription's update resource in Swagger ...



... and drill down to the details of the scheduler object


The JSON body to trigger the Subscription every hour:


{
    "folder": "/SUBS_FOLDER",
    "account": "ST_ACCOUNT",
    "application": "SUBS_APPLICATION_NAME",
    "type": "AdvancedRouting",
    "transferConfigurations": [
    {
        "id": "TRANSFER_CONF_ID",
        "site": "TRASNFER_SITE_NAME",
        "tag": "PARTNER-IN",
        "outbound": false,
        "dataTransformations": [],
        "transferProfile": null
    }],
    "schedules": [
    {
        "type": "HOURLY",
        "startDate": "START_DATE",
        "skipHolidays": false,
        "tag": "PARTNER-IN",
        "executionTimes": [
            "EXEC_TIME"
        ],
        "hourlyStep": 1,
        "hourlyType": "PERHOURS",
        "endDate": null
    }]
}


The curl query:


curl -k -u ST_ADMIN_ACCOUNT:ST_ADMIN_PASS -X PUT "https://ST_SERVER_ADDRESS:ST_ADMIN_PORT/api/v2.0/subscriptions/SUBS_ID"  -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"folder\":\"/SUBS_FOLDER\",\"account\":\"ST_ACCOUNT\",\"application\":\"SUBS_APPLICATION_NAME\",\"type\":\"AdvancedRouting\",\"transferConfigurations\":[{\"id\":\"TRANSFER_CONF_ID\",\"site\":\"TRASNFER_SITE_NAME\",\"tag\":\"PARTNER-IN\",\"outbound\":false,\"dataTransformations\":[],\"transferProfile\":null}],\"schedules\":[{\"type\":\"HOURLY\",\"startDate\":\"START_DATE\",\"skipHolidays\":false,\"tag\":\"PARTNER-IN\",\"executionTimes\":[\"EXEC_TIME\"],\"hourlyStep\":1,\"hourlyType\":\"PERHOURS\",\"endDate\":null}]}"