This document describes how to release an API using FineDataLink and how to call a released API in a FineDataLink project.
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.
Log in to the FineDataLink project, click Data Service, and create an API, as shown in the following figure.
The following introduces the API created in this example.
application/json
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.
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.)
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.
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.
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" } ]}
paging
pageNum
int
Yes
Pagination parameter
pageNum represents the number of pages, and you can set its value.
pageSize
It represents the number of data records per page, whose value is settable.
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. Enter the Body content when calling the generated API subsequently. You can click in the upper right corner to copy the Body content and paste it to another place in advance, as shown in the following figure.
3. Click the Save button at the bottom of the page.The following figure shows the page after the API is successfully generated.
To call the released API, you must bind it to an app first.
Click App List and create an app, as shown in the following figure.
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. The created app is shown in the following figure.
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
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.
Click the Activate button to release the API. So far, the API configuration is complete, as shown in the following figure.
You can click the icon below to copy the API path, as shown in the following figure.
Example: Call the API released in the "Developer: Releasing an API" section in FineDataLink.
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.
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. 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}.
Click Data Preview, as shown in the following figure.
Returned Content Description:
data
Returns the data fetched using the API.
totalNum
Returns the total number of fetched data records.
errCode
Returns the error code. For details, see Data Service Error Code Table.
Returns the number of fetched data records per page.
Returns the page number, indicating the page from which the data fetching starts.
rowCount
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.
For details about more API usage examples, see Overview of API-Based Data Fetching.
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.
The value of Authorization is shown in the following figure.
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.
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.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy