Updated on 2022-09-26 GMT+08:00

Debugging an API

Scenario

After creating an API, debug it on the API Gateway console by setting HTTP headers and body parameters to verify whether the API is running normally.

  • APIs with backend request paths containing variables cannot be debugged.
  • If an API has been bound with a request throttling policy, the policy will not work during debugging of the API.

Prerequisites

  • You have created an API group and API.
  • You have set up the backend service of the API.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and choose API Gateway.
  3. In the navigation pane, choose Dedicated Gateways. Then click Access Console in the upper right corner of a dedicated gateway.
  4. In the navigation pane, choose API Publishing > APIs.
  5. Debug an API. You can use one of the following methods:

    • In the Operation column of the API you want to debug, choose More > Debug.
    • Click the name of the target API, and click Debug in the upper right corner of the displayed API details page.
    Figure 1 Debugging an API

    On the left side, set the API request parameters listed in Table 1. On the right side, view the API request and response information after you click Send Request.

    Table 1 Parameters for debugging an API

    Parameter

    Description

    Protocol

    This parameter can be modified only if you set Protocol to HTTP&HTTPS for the API.

    Method

    This parameter can be modified only if you set Method to ANY for the API.

    Suffix

    You can define a path only if you have set Matching to Prefix match for the API.

    Path

    Request path of the API.

    Path Parameters

    This parameter can be modified only if you have defined path parameters (such as {test}) for the API.

    Headers

    HTTP headers and values.

    Query Strings

    Query string parameters and values.

    Body

    This parameter can be modified only if you set Method to PATCH, POST, or PUT for the API.

    The fields displayed on the debugging page vary according to the request type.

  6. After setting request parameters, click Send Request.

    The box on the lower right displays the response of the API request.

    • If the debugging is successful, the HTTP status code 200 and response details are displayed.
    • If the request fails to be sent, an HTTP status code 4xx or 5xx is displayed. For details, see Error Codes.

  7. You can send more requests with different parameters and values to verify the API.

    To modify the API configurations, click Edit in the upper right corner, and modify the parameters on the Edit API page.

Follow-Up Operations

After the API is successfully debugged, publish the API in a specific environment so that the API can be called by users. To ensure security of the API, create request throttling policies (see Creating a Request Throttling Policy), access control policies (Creating an Access Control Policy), and signature keys (Creating and Using a Signature Key) for the API.