Debugging an API

Scenario

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

Note

  • 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. In the navigation pane, choose Dedicated Gateways. Then click Access Console in the upper right corner of a dedicated gateway.

  3. In the navigation pane, choose API Publishing > APIs.

  4. 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.

    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.

    Query Strings

    Query string parameters and values.

    Headers

    HTTP headers and values.

    Body

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

    Note

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

  5. 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.

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

    Note

    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.