This topic describes how to test an API that is being developed or has been published.

Test an API that is being developed

You can test an API that is being developed on the Service Development tab. Before you perform such a test, create or register an API.

  1. Go to the DataService Studio page.
    1. Log on to the DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. In the top navigation bar, select the region where the target workspace resides. Find the target workspace and click DataService Studio in the Actions column.
  2. On the Service Development tab, double-click the target API in the API list.
  3. On the configuration tab of the API, click Test in the upper-right corner.
    Test button
  4. In the Test APIs dialog box, click Test to send an API request.
    The request and response details appear on the right. If the API fails the test, check the error message, modify the API settings, and then test the API again.
    You can select Save the correct response example automatically as required.
    • The system automatically generates sample failure responses and error codes when it tests an API. However, the system does not automatically generate sample success responses.

      To allow the system to save the success test result as a sample success response, you must select Save the correct response example automatically before you perform the test. If the response contains sensitive data that must be de-identified, you can manually edit the response.

    • The sample success response is an important reference for API callers, and therefore must be configured.
    • The Call Latency value is the latency of the current API request, which is used to evaluate the API performance. If the latency is long, consider optimizing the database.

Test an API that has been published

You can test an API that has been published on the Service Management tab. Before you perform such a test, publish an API. For more information, see Publish an API.

  1. On the Service Development tab, click the Service Management tab in the upper-right corner.
  2. In the left-side navigation pane, click Test APIs.
  3. Select the API to be tested from the drop-down list, and set all the request parameters of the API.
    Request Parameters section
  4. Click Test. The request and response details appear on the right.
    Note On the Test APIs page, you can only test published APIs, but not update sample success responses for APIs.