Successfully!

Error!

Example of Calling Open Platform API

  • Last update:  2023-04-28
  • Overview

    After completing the configuration of the open platform API, clients, and permissions, you can call the API to achieve the corresponding functions.

    This article provides multiple demo examples of calling API to help you use the open platform.

    Note: All the examples in this article directly call the built-in services under Basic Data API. When the decision-making platform is restarted, the data that you have configured in the services will be reset to the default data.

    To avoid this problem, you are recommended to copy the built-in services and do the configuration in the new services during actual use.

    SQL Data Service

    This demo example shows how to convert SQL to a data service for third-party use.

    API example required: [demo]Sql data service

    Managing API

    In Basic Data API, click the edit button of [demo]SQL data service.

    On the Basic page, the information has been configured by default, and no further configuration is required.

    Copy the two parameters from APIPath and APIMethod. You will use them to fill in the link when calling the API in subsequent steps.

    On the Config page, there are two items:

    • connection: the required data source connection for running SQL (such as FRDemo

    • sql: the SQL of the data sourc

    In this example, the configuration is:

    • connection = FRDemo

    • sql = SELECT * FROM 'Sales' where region = 'East China'

    Managing Clients

    Create a client and name it Test. Copy the two parameters from Client ID and Key. You will use them as the authentication when calling the API in subsequent steps.

    Managing Permissions

    In Manage Permissions, select the client Test, and enable the permission of [demo]Sql data service in the Basic Data API group to make sure the API is available.

    Previewing

    Link: http://localhost:8075/webroot/decision/sp/client/api/sql/data

    http://localhost:8075/webroot/decision/sp/client/api/ is the fixed part, and sql/data and GET represent the APIPath and APIMethod respectively.

    Write client_id and secret in Headers, and finally call the API.

    Report Dataset Service

    This Demo example shows how to provide the completed dataset data in a template to a third party.

    API example required: [demo]Report dataset service

    Managing API

    1. In Basic Data API, click the edit button of the [demo]Report dataset service to configure the API information.

    2. On the Basic page, the information has been configured by default, and no further configuration is required. Copy the two parameters from APIPath and APIMethod. You will use them to fill in the link when calling the API in subsequent steps.

    3. On the Config page, there are two items:

    • report: the source of the dataset (compared to reportlets)

    • dsName : the name of the dataset

    In this example, the configuration is:

    • report= GettingStarter.cpt 

    • dsName = ds1

    Managing Clients

    In Manage Clients, copy the two parameters from Client ID and Key in the client Test. You will use them as the authentication when calling the API in subsequent steps.

    Managing Permissions

    In Manage Permissions, select the client Test, and enable the permission of [demo]Report data service in the Basic Data API group to make sure the API is available.

    Previewing

    Link: http://localhost:8075/webroot/decision/sp/client/api/ds/data

    ds/data and GET represent the APIPath and APIMethod respectively. Write the value of client_id and secret into Headers.

    There are two ways to pass parameters. One way is to write the region information in Body: {"region": "North China"}

    Another way is to write region and North China in KEY and VALUE respectively in Params. Then add the parameter value to the link suffix: ?region = North China

    The two ways can achieve the same effect.

    Report Data Service

    This demo example shows how to make the data that cannot be extracted from database to a report, and provide it as a data service to a third party.

    API example required: [demo]Report data service

    Managing API

    1. In Basic Data API, click the edit button of the [demo]Report data service to configure the API information.

    2. On the Basic page, the information has been configured by default, and no further configuration is required. Copy the two parameters from APIPath and APIMethod. You will use them to fill in the link when calling the API in subsequent steps.

    3) On the Config page, there are two items:

    • report: the report path of the data source (compared to reportlets)

    • tag: the sheet name of the data source

    In this example, the configuration is:

    • report = open platform test. cpt

    • tag=sheet1

    Template download:

    Open platform test.zip

    Note: 1. The data of this template is from FRdemo database. You can download and use it directly. 

      2. This API is not suitable for complex templates or templates with a large data volume.

    Managing Clients

    In Manage Clients, copy the two parameters from Client ID and Key in the client Test. You will use them as the authentication when calling the API in subsequent steps.

    Managing Permissions

    In Manage Permissions, select the client Test, and enable the permission of [demo]Report data service in the Basic Data API group to make sure the API is available.

    Previewing

    Link: http://localhost:8075/webroot/decision/sp/client/api/list/report/data.

    list/report/data and GET represent the APIPath and APIMethod respectively. Write the value of client_id and secret into Headers.

    Report Data Grouping Aervice

    This demo example shows how to make the data that cannot be extracted from database to a report, and provide it as a data service to a third party.

    API example required: [demo]Report data grouping service

    Managing API

    1. In Basic Data API, click the edit button of the [demo]Report data grouping service to configure the API information.

    2. On the Basic page, the information has been configured by default, and no further configuration is required. Copy the two parameters from APIPath and APIMethod. You will use them to fill in the link when calling the API in subsequent steps.

    3. On the Config page, there are two items:

    • report: the report path of the data source (compared to reportlets)

    • tag: the sheet name of the data source

    In this example, the configuration is:

    • report = Open Platform Test.cpt

    • tag=sheet1

    Note: 1. The open platform test template is the same as Example 4.

    2. Same as the report data service, this API is not suitable for complex templates or templates with a large data volume.

    Managing Clients

    In Manage Clients, copy the two parameters from Client ID and Key in the client Test. You will use them as the authentication when calling the API in subsequent steps.

    Managing Permissions

    In Manage Permissions, select the client Test, and enable the permission of [demo]Report data grouping service in the Basic Data API group to make sure the API is available.

    Previewing

    Link: http://localhost:8075/webroot/decision/sp/client/api/group/report/data.

    group/report/data and GET represent the APIPath and APIMethod respectively. Write the value of client_id and secret into Headers.

    From the result image, you can see that the data output by this API is consistent with the report data service API, but different in format.

    From the data output by this API, you can see the contents of the template are divided into two parts, ‘title’ and ‘items’. You can choose different APIs according to your needs.

    Data Entry Service

    This demo example shows how to submit data without preview to improve the efficiency of data entry.

    API example required: [demo]Data Entry service

    Example One: Single-line Data Entry

    1. Managing API

    a. In Basic Data API, click the edit button of the [demo]Data Entry service to configure the API information.

    b. On the Basic page, the information has been configured by default, and no further configuration is required. Copy the two parameters from APIPath and APIMethod. You will use them to fill in the link when calling the API in subsequent steps.

    c. On the Config page, there is one item:

    • report: the report path of the data source (compared to reportlets

    In this example, the configuration is:

    • report = Example of data entry (single line).cp

    Template download:

    Example of data entry(single line).zip

    In the template, write four parameters: a, b, c, and d.

    2. Managing Clients

    In Manage Clients, copy the two parameters from Client ID and Key in the client Test. You will use them as the authentication when calling the API in subsequent steps.

    3. Managing Permissions

    In Manage Permissions, select the client Test, and enable the permission of [demo]Data Entry service in the Basic Data API group to make sure the API is available.

    4. Previewing

    Link: http://localhost:8075/webroot/decision/sp/client/api/write/report/data.

    group/report/data and GET represent the APIPath and APIethod respectively. Write the value of client_id and secret into Headers.

    In Params, assign values to the four parameters: a, b, c, and d.

    A new line has been added to the table.

    Example Two: Multi-line Data Entry

    1. Managing API

    a. In Basic Data API, click the edit button of the [demo]Data Entry service to configure the API information.

    b. On the Basic page, the information has been configured by default, and no further configuration is required. Copy the two parameters from APIPath and APIMethod. You will use them to fill in the link when calling the API in subsequent steps.

    c. On the Config page, there is one item:

    • report: the report path of the data source (compared to reportlets)

    In this example, the configuration is:

    • report = Example of data entry.cpt

    Template download:

    Example of data entry.zip

    2. Managing Clients

    In Manage Clients, copy the two parameters from Client ID and Key in the client Test. You will use them as the authentication when calling the API in subsequent steps.

    3. Managing Permissions

    In Manage Permissions, select the client Test, and enable the permission of [demo]Data Entry service in the Basic Data API group to make sure the API is available.

    4. Previewing

    Link: http://localhost:8075/webroot/decision/sp/client/api/write/report/data.

    group/report/data and GET represent the APIPath and APIMethod respectively. Write the value of client_id and secret into Headers.

    Write in the required contents according to the format in the Body.

    Two new lines have been added to the table.

    Attachment List


    Theme: Decision-making Platform
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback