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
You can download the sample data: en_comment.xlsx.
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.
Click Data Preview, as shown in the following figure.
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.
You can also change the data type of the field, as shown in the following figure.
The following figure shows the detailed setting for JSON generation.
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.
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.
You can call this parameter in subsequent nodes, as shown in the following figure.
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).
Save and run the task. After the task is successfully executed, data is pushed to the business system.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy