Skip to main content

Run scheduled saved import tutorial

In this tutorial, you will use the Varicent Incentives REST APIs to run a scheduled saved import that will upload data to your model.

Prerequisites

  1. On the Varicent server, you have saved the file that contains the data that you want to import. For more information on creating saved import files, see Managing Saved Imports.

  2. In Scheduler, you have created a task to run the saved import file, which uploads the data in the file to your model. For more information on creating tasks in Scheduler, see Scheduler Module.

  3. You have obtained your Varicent API Key as outlined in REST API authentication and headers.

Overview

In this tutorial, we will be using the following two REST API calls to run the saved import:

Get schedule items

This call gets the ID of the Scheduler task that runs the saved import file.

Run schedule item

This call uses the ID obtained by the Get schedule items call to run the Scheduler task that uploads the data in the saved import file.

We will then use the following REST API calls to see if the task was completed successfully:

GET live activities

This call is used to see if the task is still running.

Get scheduled item

This call is used to check the status of the last task run.

Get audit scheduler

This call is used to view Scheduler log information if the task encountered an error.

Retrieving the task ID

First, use the Varicent Incentives REST API call that retrieves a list of all the Scheduler tasks and subtasks.

  1. Make the following request:

    GET /api/v1/scheduleitem

    For example,

    curl -X GET -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/scheduleitem
  2. In the response body, find the Scheduler task that was created to run the saved import, and note the ID.

    {
    "id": 12,
    "name": "CompPlanApproval Import",
    "scheduleItemType": "Import",
    "order": 7,
    "lastRun": "2012-09-06T05:01:09.473Z",
    "lastRunStatus": "Success",
    "activation": "Enabled",
    "nextRun": "0001-01-01T00:00:00",
    "parent": 1,
    "settings": {
        "schedulerSettingsId": 0,
        "scheduleItemId": 12,
        "emailOnFailure": false,
        "emailOnSuccess": false,
        "stopOnFailure": false,
        "stopToolOnTimeout": false,
        "isGlobal": false,
        "overrideChildSettings": false,
        "successEmails": [],
        "failEmails": [],
        "externalToolTimeout": 0,
        "enableRetries": false,
        "version": {
            "rowVersion": 1801131
        }

Running the Scheduler task

Next, use the ID obtained from the Get scheduler items call to run the saved import task in Varicent Incentives .

  1. Make the following request:

    POST /api/v1/rpc/scheduleitem/{id}/run

    For example,

    curl -X POST -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/rpc/scheduleitem/12/run
  2. In the request response, note the returned ProgressId. In this example, the ProgressID is 15850.

    {
        "completedactivities": "api/v1/completedactivities/15850",
        "liveactivities": "api/v1/liveactivities/15850"     
    }

Checking the Scheduler task run status

Finally, you can run several calls to check on the status of the Scheduler task, and get Scheduler log information if you encounter an error.

  1. You can make the following request to see if the task is running:

    GET /api/v1/liveactivities/{ProgressId}

    Note

    You should have obtained the ProgessId from Step 2 of Running the Scheduler task.

    For example,

    curl -X GET -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/liveactivities/15850

    The response returns a status of Running if the task is still running. If the task has completed, the response returns a message indicating the task was not found.

  2. You can make the following request to see if the task completed successfully or encountered an error:

    GET api/v1/scheduleitem/{ProgressId}

    Note

    You should have obtained the ID in Retrieving the task ID.

    For example,

    curl -X GET -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https:// YOUR_ICM10_API_SERVER_ADDRESS/api/v1/scheduleitem/12

    The response returns a lastRunStatus of Success if the task completed successfully. If the task encounters an error, the response will return a lastRunStatus of Error.

  3. If the task encountered an error, you can make the following request to view the Scheduler log details:

    GET api/v1/auditschedulers?offset=0&limit=1

    Note

    The offset and limit parameters ensure that only the last Scheduler log entry is returned.

    For example,

    curl -X GET -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https:// YOUR_ICM10_API_SERVER_ADDRESS/api/v1/auditschedulers?offset=0&limit=1

    The response returns the error message details.