When creating an API, if you want to publish it to API Gateway, you must test the API to verify whether the request parameters and return values meet your expectations. You can also test a published API. This topic describes how to test both APIs under development and published APIs.
Background information
API testing involves directly accessing actual data sources or backend services to call the API, which consumes DataService Studio resource group resources and incurs costs. For billing details, see DataService Studio public resource group billing: pay-as-you-go.
Test an API that is being developed
Testing an API that is being developed refers to testing in the Service Development page (development environment). You need to first create or register an API.
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose . On the page that appears, select the desired workspace from the drop-down list and click Go to DataService Studio.
Find the Service Management tab on the Service Development page. Under API Management, click the Published APIs tab, and then click Operation Test in the column of the API that you want to test.
Test the API.
In the API Test dialog box, enter the values of the request parameters.
Click Start Test to trigger the API test.
You can view the Request Details and Return Content of the API on the right.
The Response Time is the response time of this API request, which helps you evaluate the API performance. If the latency is high, we recommend that you optimize the query logic or data source.
If the API test fails, check the error message, modify the API settings, and then retest the API.
Test an API that is published
Testing a published API refers to testing in the Service Management page (production environment). You need to first publish the API. For more information, see Publish an API.
On the DataService Studio page, click Service Management at the top.
In the left navigation bar, click API Test.
Select the API that you want to test from the drop-down list and ensure that the values of the Request Parameters of the API are completely configured.
Click Start Test and view the Request Details and Return Content on the right.
NoteThe API Test page only provides the online API testing function and does not support updating the normal return example of the API.
When the API is configured to display Paginated Results, whether the returned data is sorted depends on the data source service. You can configure Sort Field for the API in Codeless UI mode to sort the returned data, or add
ORDER BY
to the SQL code in Code Editor mode to sort the query results.
What to do next
After you test an API that is being developed, you can publish the API. This allows other users to call the API. For more information about how to publish an API, see Publish an API.