Debugging an API
Function
This API is used to debug the definition of an API in a specified environment. The API caller must have the permissions required for operating this API.
URI
The following table lists the HTTP/HTTPS request method and URI of the API.
| Request Method | URI |
|---|---|
| POST | /v1/{project_id}/apigw/instances/{instance_id}/apis/debug/{api_id} |
The following table lists the parameters in the URI.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID, which can be obtained by the administrator on the My Credentials page. |
| instance_id | Yes | String | Instance ID, which can be obtained from the dedicated gateway information on the API Gateway console. |
| api_id | Yes | String | API ID |
Request
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| scheme | Yes | String | Request protocol, which can be:
|
| method | Yes | String | Request method, which can be:
|
| domain | No | String | Access domain name of the API. If no value is specified, one of the following default values will be used based on the setting of mode:
|
| path | Yes | String | Request path of the API, starting with a slash (/) and with up to 1024 characters NOTE: The request path must meet path requirements so that it can be correctly decoded after percent-encoding. |
| query | No | Dictionary | Query strings, with each value being a character string array. Each parameter name must meet the following requirements:
|
| header | No | Dictionary | Header parameters, with each value being a character string array. Each parameter name must meet the following requirements:
NOTE: Each header name is normalized before use. For example, x-MY-hEaDer is normalized as X-My-Header. |
| body | No | String | Message body, with a maximum length of 2,097,152 bytes. |
| mode | Yes | String | Debugging mode, which can be:
|
| app_key | No | String | AppKey used in the debugging request |
| app_secret | No | String | AppSecret used in the debugging request |
| stage | No | String | Running environment specified in the debugging request. This parameter is valid only when mode is set to CONSUMER. If no value is specified, RELEASE is used. |
Example request:
{
"mode": "DEVELOPER",
"scheme": "HTTPS",
"method": "GET",
"path": "/test",
"query": {
"city": [
"shenzhen",
"beijing"
]
},
"header": {
"X-My-City": [
"shenzhen",
"beijing"
]
}
} Response
| Parameter | Type | Description |
|---|---|---|
| request | String | Body of the debugging request |
| response | String | Body of the debugging response, with a maximum length of 2,097,152 bytes. Any content beyond this threshold will be truncated. NOTE: Any content beyond the length limit will be truncated, and text [TRUNCATED] will be added to the response body. |
| latency | String | Debugging duration in milliseconds |
| log | String | Debugging logs |
Example response:
{
"request": "GET /test?city=shenzhen&city=beijing HTTP/1.1\r\nHost: edf94892b11d440795562cb81c5be059.apigw.example.com\r\nUser-Agent: APIGatewayDebugClient/1.0\r\nX-Apig-Mode: debug\r\nX-My-City: shenzhen\r\nX-My-City: beijing\r\n\r\n",
"response": "HTTP/1.1 200 OK\r\nContent-Length: 33\r\nConnection: keep-alive\r\nContent-Type: application/json; charset=utf-8\r\nDate: Fri, 24 Aug 2018 10:36:47 GMT\r\nServer: api-gateway\r\nX-Apig-Latency: 13\r\nX-Apig-Ratelimit-Api: remain:92,limit:100,time:1 minute\r\nX-Apig-Ratelimit-Api-Allenv: remain:9,limit:10,time:1 second\r\nX-Apig-Upstream-Latency: 1\r\nX-Request-Id: 12f69943cc2fa4f8a3674ee947655339\r\n\r\n{\"version\":\"4.0.12.201808190004\"}",
"latency": "12",
"log": ""
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 500 | Internal Server Error |
Last Article: Querying the Runtime Definition of an API
Next Article: App Management
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.