Data Service Example

  • Last update: April 30, 2025
  • Overview

    This document describes how to release an API using FineDataLink and how to call a released API in a FineDataLink project.

    iconNote:
    If you want to call a released API, you need to first bind it to an app. Three app authentication methods are available: No AuthenticationAppCode, and Digest Signature. This document introduces the first two authentication methods.

    Developer: Releasing an API

    Preparation

    1. Prepare an independently deployed FineDataLink project with registered function points related to Data Service. For details about prerequisites that need to be noted, see Prerequisite.

    2. You are advised to use the latest version of Google Chrome or Microsoft Edge, as compatibility issues may occur in other browsers.

    3. Data source configuration:

    • For details about the data sources supported by Data Service, see Data Sources Supported by Data Service.

    • Before creating an API in Data Service, ensure FineDataLink is connected to the source database containing the processed data to be published, so that you can select the data source when publishing the API.For details, see Data Connection Configuration.

    Creating an API

    Log in to the FineDataLink project, click Data Service, and create an API, as shown in the following figure.

    2.2.png

    Configuring the API

    The following introduces the API created in this example.

    Request Method
    POST
    Request Body Format

    application/json

    API Content

    Data fetched from the SORDER table in the demotest database where the owner region corresponds to the values of the Area parameter.

    API configuration requires setting API information, filling in release content and parameters, and conducting a preview test. For details about the specific setting items in these steps, see Overview of API Release.

    API Information

    Rename the API Doc_test. You can leave the API description empty. Set Request Method and Request Body Format to POST and application/json, respectively.

    Fill in the path of the API to be released. The path is part of the API address. For details, see the “Binding the API to an App” section.Path supports English letters, numbers, underscores (_), hyphens (-), and forward slashes (/). In this example, fill in doc_test.

    If no query result is returned within the period set in Timeout, the API will report a timeout error. The default value of Timeout is 10000 ms, which is not modified in this example.

    If you want to call a released API, you need to first bind it to an app. In this example, the API is bound to an app in subsequent steps. (If you have already created an app, you can also bind the API to it in this step.)

    2.3.1.png

    Release Content and Parameter

    Fetch data from the SORDER table in the demotest database where the owner region corresponds to the values of the Area parameter, as shown in the following figure.

    Click Refresh and Preview to view the fetched data.

    2.3.2.png

    Preview Test

    1. Assign the value East China to the parameter Area and click Test Calling to view the fetched data on the right, as shown in the following figure.

    2.3.3-1.png

    The Body content of this API is as follows.

    Keep the Body content format consistent with the following format when calling the API.

    {
      "paging": {
        "pageSize": 10,
        "pageNum": 1
      },
      "params": [
        {
          "name": "Area",
          "value": "East China"
        }
      ]
    }
    NameTypeMandatory or NotDescription

    paging

    pageNum

    int

    Yes

    Pagination parameter

    pageNum represents the number of pages, and you can set its value.

    pageSize

    int

    Yes

    It represents the number of data records per page, whose value is settable.

    iconNote:
    The maximum number of data records per page in a single API call is limited to 10,000.

    params

    object

    No

    Custom parameter

    If you set a custom parameter when releasing the API but this parameter is not passed in the request, an error will be returned.

    The Headers content is shown in the following figure.

    2.3.3-2.png

    2. Enter the Body content when calling the generated API subsequently. You can click b.png in the upper right corner to copy the Body content and paste it to another place in advance, as shown in the following figure.

    2.3.3-3.png

    3. Click the Save button at the bottom of the page.The following figure shows the page after the API is successfully generated.

    2.3.3-4.png

    Binding the API to an App

    To call the released API, you must bind it to an app first.

    Creating an App

    Click App List and create an app, as shown in the following figure.

    2.4.1.png

    Setting the App Authentication Method

    Scenario One: No Authentication

    1. Modify Name to Doc_app. The description can be empty and is left empty in this example.

    Select No Authentication as App Authentication Method. For details about APPCode and Digest Signature Authentication, see Binding an API to an Application. Bind the API created in the "Configuring the API" section to this app, as shown in the following figure.

    2.4.2-1.png

    2. The created app is shown in the following figure.

    2.4.2-2.png

    The API address format is FineDataLink server address /service/publish/App ID (the highlighted part in the above figure) / Path (Doc_test set in the "API Information" section). The following is the address of the API generated in this example.

    http://192.168.5.175:8089/webroot/service/publish/ae1344e6-447a-47b7-87eb-8d6451232d4c/doc_test

    Scenario Two: AppCode

    1. Modify Name to Doc_app. The description can be empty and is left empty in this example.

    Select AppCode as App Authentication Method. Bind the API created in the "Configuring the API" section to this app, as shown in the following figure.

    2.4.2-3.png

    2. The created app is shown in the following figure.

    2.4.2-4.png

    The API address format is FineDataLink server address /service/publish/App ID (the highlighted part in the above figure) / Path (Doc_test set in the "API Information" section). The following is the address of the API generated in this example.

    http://192.168.5.175:8089/webroot/service/publish/ae1344e6-447a-47b7-87eb-8d6451232d4c/doc_test

    Activating the API

    Click the Activate button to release the API. So far, the API configuration is complete, as shown in the following figure.

    2.5-1.png

    You can click the a.png icon below to copy the API path, as shown in the following figure.

    2.5-2.png

    Caller: Calling the Released API

    Example: Call the API released in the "Developer: Releasing an API" section in FineDataLink.

    Preparation

    You (as the caller) must have Use permission on the API.For details, see sections "Enabling Data Service API Management" and "Assigning Use Permission on Data Service Task" in Data Service API Management Permission.

    Calling the Generated API in FineDataLink

    Scenario One: App Authentication Method Set to No Authentication

    1. Click Data Development and create a scheduled task.

    2. In this way, you can assign values to the parameter Area when calling the API created in the "Configuring the API" to fetch data from the SORDER table in the demotest database where the owner region corresponds to the values of the Area parameter.

    Click Parameter List and add a parameter Area with the value East China, as shown in the following figure.

    3.2.1-1.png

    3. Drag a Data Synchronization node onto the page, enter the API-related information, and call the API, as shown in the following figure.

    You can directly copy and paste the Body content from the "Preview Test" section and modify the value of the parameter Area to ${Area}.

    3.2.1-2.png

    Click Data Preview, as shown in the following figure.

    3.2.1-3.png


    Returned Content Description:

    NameTypeDescription

    data

    object

    Returns the data fetched using the API.

    totalNum

    int

    Returns the total number of fetched data records.

    errCode

    int

    Returns the error code. For details, see Data Service Error Code Table.

    pageSize

    int

    Returns the number of fetched data records per page.

    pageNum

    int

    Returns the page number, indicating the page from which the data fetching starts.

    rowCount

    int

    Returns the number of data records on the current page.

    It is related to the pageNum value.For example, there are 12 data records in total. The pageNum value passed in is 2, and the pageSize value is 10.The system will query the data from the second page, and the actual returned value will be 2.

    message

    string

    Returns success if the API call is successful.

    Returns the specific error reason if the API call fails.

    If you input data in Response Body Processing, you can parse the data field, as shown in the following figure.

    You can also drag a Data Transformation node onto the page, enter the Data Transformation node, add an API Input operator to obtain API data, and add a JSON Parsing operator to parse the data field.

    3.2.1-4.png

    For details about more API usage examples, see Overview of API-Based Data Fetching.

    Scenario Two: App Authentication Method Set to AppCode

    Unlike the "Scenario One: App Authentication Method Set to No Authentication" section, when calling an API, you need to set Authorization, as shown in the following figure.

    3.2.2-1.png

    The value of Authorization is shown in the following figure.

    3.2.2-2.png

    Click Data Preview, as shown in the following figure.

    3.2.2-3.png

    API O&M

    For details, see Data Service O&M.

    You can view the API quantity, number of activated APIs, and number of deactivated APIs by selecting a specified API folder or API task under O&M Center > Data Service > API Management, as shown in the following figure.

    4-1.png

    You can view the total number of calls, the number of server failures, the number of client failures, and average call duration by selecting a specified task or folder under O&M Center > Data Service > Call Record, as shown in the following figure.

     4-2.png

    附件列表


    主题: Data Service
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy