You want to publish an API that enables multi-value filtering on specific table columns, which can be implemented by passing multiple values through a single parameter via the SQL IN() clause.
This document uses the SORDER table as an example to illustrate how to publish the table data as an API that enables fetching data of multiple regions (such as North China, East China, and South China) simultaneously.
Click Data Service, choose New > API Service, enter the name of the API service, and click OK, as shown in the following figure.
The following figure shows the setting page.
SELECT * FROM `demotest`.`SORDER` where OWNER_REGION IN ($Area)
The following table describes the setting items.
For details about each setting item, see Overview of API Release.
SQL Statement
Enter the SQL statement. This example uses MySQL syntax. Adjust the statements accordingly if you use other databases.
Pagination Query
Disable Pagination Query. The API to be generated will return data without pagination after being called.
Custom Parameter
Use East China and North China as debug values of the custom parameter Area, which can be used to preview query results. (Data whose OWNER_REGION value is East China or North China will be returned).
1. Select POST as Request Method and set the path to Doc_489. Custom path is supported.
Add an App. If no App has been created, you can skip this step and bind the API to an App in App List after completing the API creation. For details, see Binding an API to an Application. The binding step is mandatory; otherwise, the API cannot be called later.
Set Request Body Format to application/json, as shown in the following figure.
2. Click Test Call in the lower right corner to debug the API. The parameter value of Area defaults to the debug values East China and North China, as shown in the following figure.
3. Click Save and Activate. The API is created and activated successfully, as shown in the following figure.
If you do not bind the API to a specified App when publishing the API, you can still manage the published API by binding it to an App in App List to ensure that the API can be called.
For details about using published APIs, see Using APIs Released in Data Service (POST application/json Request). The following figure shows the call effect.
For details about managing published APIs, see Data Service O&M.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy