All Products
Search
Document Center

DataWorks:Test an API

Last Updated:Dec 09, 2024

After an API is created, if you want to publish the API to API Gateway, you must test the API in DataService Studio to check whether the request parameters and return values of the API meet your business requirements. You can also test a published API. This topic describes how to test an API that is being developed and an API that is published.

Background

When you test APIs, the shared resource group for DataService Studio is used to access data sources or backend services to call APIs. You are charged for the resource group based on the number of API calls and the execution time of the API calls. For more information about the billing details, see DataService Studio.

Test an API that is being developed

You can test an API that is being developed on the Service Development tab of the DataService Studio page. Before you perform the test, you must create or register the API.

  1. Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose Data Development and Governance > DataService Studio. On the page that appears, select the desired workspace from the drop-down list and click Go to DataService Studio.

  2. On the DataService Studio page, click Service Management in the top navigation bar. In the left-side navigation pane of the Service Management tab, click Manage APIs. On the Published APIs tab of the Manage APIs page, find the API that you want to test and click Test in the Actions column.

  3. Test the API.

    In the Test APIs dialog box, configure all request parameters of the API.

  4. Click Test to trigger the API test.

    • You can view information that is displayed in the Request Details and Response Details sections on the right side of the Test APIs page.

    • The API call latency value is the latency of the current API request. The value is used to 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

You can test an API that is published on the Service Management tab of the DataService Studio page. Before you perform the test, you must submit and publish the API. For more information, see Publish an API.

  1. On the DataService Studio page, click Service Management in the upper-right corner.

  2. In the left-side navigation pane, click Test APIs.

  3. Select the API that you want to test from the drop-down list, and confirm that all request parameters of the API are configured.

    请求参数

  4. Click Test to trigger the API test. You can view information that is displayed in the Request Details and Response Details sections on the right side of the Test APIs page.

    Note

    On the Test APIs page, you can only test published APIs. You cannot update sample success responses for APIs.

What to do next

After you perform a test on an API that is being developed, you can publish the API. This way, other users can call the API. For more information about how to publish an API, see Publish an API.