Skip to main content

Modify table data tutorial

Prerequisites

  1. You have created tables in Composer. For more information on creating tables, see Introducing the Composer module.

  2. 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 REST API calls to retrieve the name of the table and the ID of the input form that contains the data that you want to modify:

Get table name

This call is gets the name of the table that contains the data that you want to modify.

Get input form ID

This call uses the table name retrieved by the Get table name call to get the ID of the input form that contains the data that you want to modify.

We will then use the following REST API calls to modify the data:

Add table data

This call adds a row of data to the table.

Update table data

This call modifies a row of data in the table.

Delete table data

This call deletes a specified row of data in the table.

Adding a row of data to a table

In Varicent Incentives, you can use the REST API to add a row of data to a table. If you need to add multiple rows of data to a table, see Adding multiple rows of data to a table.

If you do not know the exact name of your table, use the GET table name call.

If the table has more than one input form, use the GET input form call to find the input form ID. If the table does not contain additional input forms, the input form ID is zero (0).

  • Make the following request to add a single row of data to a table:

    POST /api/v1/customtables/{tablename}/inputforms/{inputformID}/data

    with the data you want to add contained in the request body:

    Note

    The request body must be in JSON format.

    {
    "rows":[["<column1data>","<column2data>"]],
    "inputFormId":<inputformid>,
    "effectiveDate":<effectivedate>
    }

    If the table is not effective dated, then the effectiveDate is null.

    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/customtables/Demo/inputforms/0/data

    Request Body:

    {
    "rows":[["AE001","Dan Huddle"]],
    "inputFormId":0,
    "effectiveDate":null
    }

Adding multiple rows of data to a table

If you want to add multiple rows of data to a table, use the following REST API instead, with the data you want contained in the request body:

POST /api/v1/customtables/{tablename}/inputforms/{inputformID}/data/rows

{
"rows":[
    ["<row1column1data>","<row1column2data>"]
    ["<row2column1data>","<row2column2data>"]
],
"inputFormId":<inputformid>,
"effectiveDate":<effectivedate>
}

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/customtables/Demo/inputforms/0/data/rows

Request body:

{
"rows":[
    ["AE001","Dan Huddle"]
    ["AE002", "Anita Harper"]
],
"inputFormId":0,
"effectiveDate":null
}

Caution

We don't recommend using API calls to import data in bulk. Best practice is to use the data import tools available in the Data module of Incentives.

Updating a row of data in a table

In Varicent Incentives, you can use the REST API to modify a row of data in a table.

If you don't know the exact name of your table, use the GET table name call.

If the table has more than one input form, use the GET input form call to find the input form ID. If the table does not contain additional input forms, the input form ID is zero (0).

  • Make the following request:

    PATCH /api/v1/customtables/{tablename}/inputforms/{inputformID}/data

    with the old data and the new data that you want to add contained in the request body:

    Note

    The request body must be in JSON format.

    {
    "oldRows":[["<oldColumn1Data>"","<oldColumn2Data>"]],
    "rows":[["<newColumn1Data>","<newColumn2Data>"]],
    "inputFormId":<inputFormID>,
    "effectiveDate":<effectiveDate>,
    "overwrite":[null]
    }

    If the table is not effective dated, then the effectiveDate is null.

    For example,

    curl -X PATCH -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/customtables/Demo/inputforms/0/data

    Request Body:

    {
    "oldRows":[["AE001","Dan Huddle"]],
    "rows":[["AE001","Daniel Huddle"]],
    "inputFormId":0,
    "effectiveDate":null,
    "overwrite":[null]
    }

Deleting a row of data from a table

In Varicent Incentives , you can use the REST API to delete a specific row of data from a table.

If you do not know the exact name of your table, use the GET table name call.

If the table has more than one input form, use the GET input form call to find the input form ID. If the table does not contain additional input forms, the input form ID is zero (0).

  • Make the following request:

    DELETE /api/v1/customtables/{tablename}/inputforms/{inputformID}/data

    with the data you want to delete contained in the request body:

    Note

    The request body must be in JSON format.

    {
    "rows":[["<column1data>","<column2data>"]],
    "inputFormId":<inputformid>,
    "effectiveDate":<effectivedate>
    }

    For example,

    curl -X DELETE -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/customtables/Demo/inputforms/0/data

    Request Body:

    {
    "rows":[["AE001","Dan Huddle"]],
    "inputFormId":0,
    "effectiveDate":null
    }