API Output Example

  • Last update: January 10, 2025
  • Overview

    Logic Description of API Output has introduced the basic functions of the API Output operator in FineDataLink, through which you can realize data interaction among business systems via APIs, thus achieving application integration.

    This document illustrates the process through a specific example. After you transform user data in a table format into JSON data, use the API Output operator to write it into an API of the business system to trigger business processes, thus achieving data interaction.

    Operation Flow

    1679998149cKQr_fix1736412764.jpeg

    Procedure

    You can download the sample data: en_comment.xlsx.

    Fetching Data

    Drag a Data Transformation node to the design page and click the node. Drag a DB Table Input operator to the configuration page and use the SQL statement shown in the following figure to fetch the data that needs to be output to an API.

    2025-01-03_15-42-50.png

    Click Data Preview, as shown in the following figure.

    2025-01-03_15-43-20.png

    Generating JSON Data

    The data to be written into the API should be JSON data, so you need to transform the original data in the database table format into JSON data.

    The following is an example of JSON data:

    {
                "fields": {
                           "summary": "Very helpful",
                           "components": {
                                      "name": [
                                                  "FR11"
                                      ]
                           },
                           "custom_field_14904": "https://help.fanruan.com/finereport-en/doc-view-2586.html",
                           "description": "Supported Data Connection Range"
                }
    }

    Drag a JSON Generation operator to the design page, and configure JSON Field and JSON Setting. For details about JSON configuration, see JSON Generation.

    You can implement JSON nesting using sub-objects and subarrays, and select the corresponding fields, as shown in the following figure.

    2025-01-03_15-48-45.png

    You can also change the data type of the field, as shown in the following figure.

    2025-01-10_14-26-38.png

    The following figure shows the detailed setting for JSON generation.

    2025-01-03_15-55-24.png

    Outputting the API

    Add an API Output operator, configure the API to which the JSON data needs to be written, and select JSON on the Body tab page, as shown in the following figure.

    2025-01-10_10-42-05.png

    If you want to use the return value of the API, you can select Set Return Value as Parameter in Processing Method to set the return value as a parameter for subsequent use.

    You can set the parameter name and add a default value to facilitate debugging.

    For example, if JSON data is output to the API successfully, {"code":200,"message":"success","self":"http://192.168.101.211:10636/webroot/service/publish/305234da-d305-4f01-beb5-a6cbd55b60bf/doc_test?"} is returned.

    You can set this return value as a parameter, as shown in the following figure.

    2025-01-10_10-56-53.png

    You can call this parameter in subsequent nodes, as shown in the following figure.

    2025-01-10_10-54-14.png

    • The execution status of the API Output operator is bound to the HTTP response status. During runtime and the preview, the execution is successful only when the response status code is 2xx. Otherwise, an error is reported, and the error message includes the specific status code and the response body details.

    • Set Return Value as Parameter is a checkbox (deselected by default). When it is selected, you can set Parameter Name and Default Value (a multi-line text that you copy from the API document).

    Running the Task

    Save and run the task. After the task is successfully executed, data is pushed to the business system.


    附件列表


    主题: Data Development - Scheduled Task
    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