The API includes a parameter named Data_ID, which allows you to fetch the specific data associated with the given data ID from the API.
Data IDs (Data_ID values) are stored in a database. You want to fetch data records with these IDs from the API, retrieving one data record per API call.
Use the Parameter Assignment node to fetch the values of Data_ID from the database and output them as parameter values. Pass these values through the parameter to the Loop Container node.
Drag a Data Synchronization node into the Loop Container node and configure it to fetch data from the API. The loop processes one data ID per iteration and terminates upon exhausting all data IDs.
You can download the database data: orderlist.xlsx
API data: http://192.168.101.211:10636/webroot/service/publish/72d0c1a3-06d3-41fe-b2b5-3dd323fc6654/Doc_310
The API request method is POST.
The authentication type is Other, and the value is AppCode a970c48a-7d44-44ce-968c-be9ad12ea5b7.
The API request body includes a parameter named Data_ID, which allows you to fetch the specific data associated with the given data ID from the API.
Each request to this API can retrieve data for only a single data ID.
1. Create a scheduled task.
2. Since you want to retrieve API data corresponding to specific Data_ID values, you need to extract the Data_ID values stored in the database and output them as parameter values first.
Drag in a Parameter Assignment node and configure it to extract the Data_ID values from the Order_List_310 database table, as shown in the following figure.
Click Data Preview to view the extracted Data_ID values, as shown in the following figure.
A total of 830 parameter values are output. During the loop iteration, only one parameter value is used at a time, which means the loop will be executed 830 times.
Output Data_ID as a parameter, as shown in the following figure.
You are advised to set a debug value for the parameter to facilitate viewing the effects when subsequent nodes reference the parameter. The debug value does not participate in actual execution.
For details about the Parameter Assignment node, see Parameter Assignment.
When a parameter is used as a loop variable, its value is treated as a one-dimensional array, allowing containers to iterate over each element. When the parameter is used in other scenarios, its values remain in the string format.
Drag in a Loop Container node and pass the parameter values output in the section "Extracting Data_ID from the Database and Outputting it as a Parameter" to the loop container. The loop container will iterate over these parameter values.
Select For-Each Loop as the loop type and select Data_ID in Object. Since 830 parameter values were output in the section "Extracting Data_ID from the Database and Outputting it as a Parameter", the loop will need to execute 830 times. Therefore, the loop limit should be set higher than 830. In this example, it is set to 10,000 (the maximum number of iterations supported by Loop Container), as shown in the following figure.
For details about Loop Container, see Description of Loop Container Logic.
1. Drag a Data Synchronization node into the Loop Container node and configure it to retrieve data from the API.
For details about API-based data fetching, see Data Synchronization - API.
This API requires authentication, so you must provide authentication information when calling the API, as shown in the following figure.
The request body of the API contains the Data_ID parameter, which is used to retrieve data. Therefore, reference the Data_ID parameter in the request body. During each loop iteration, data corresponding to a single data ID is retrieved until all Data_ID values have been processed.
Click Data Preview to view API data corresponding to the debug value set in the section "Extracting Data_ID from the Database and Outputting it as a Parameter", as shown in the following figure.
2. The data retrieved in each loop iteration is synchronized to the database table, as shown in the following figure.
In the example of this document, the Write Method is set to Write Data into Target Table Directly.
Click Run to execute the task. After a successful execution, the log is displayed, as shown in the following figure.
Choose Statistics > Loop Container, where you can view the loop execution record. The loop has been executed 830 times, writing one piece of record each time, as shown in the following figure.
After successful execution, a new data table is added to the database, containing the API data corresponding to the data IDs in the database table Target_310. The page is shown in the following figure.
You can click the Publish button to publish the task to Production Mode, as shown in the following figure.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy