Updated on 2023-04-06 GMT+08:00

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.

Table 1 HTTP/HTTPS request method and URI

Request Method

URI

POST

/v1.0/apigw/apis/debug/{api_id}

The following table lists the parameter in the URI.

Table 2 Parameter description

Parameter

Mandatory

Type

Description

api_id

Yes

String

API ID

Request

Table 3 Parameter description

Parameter

Mandatory

Type

Description

scheme

Yes

String

Request protocol, which can be:

  • HTTP
  • HTTPS

method

Yes

String

Request method, which can be:

  • GET
  • POST
  • PUT
  • DELETE
  • HEAD
  • PATCH
  • OPTIONS

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:

  • For DEVELOPER, the subdomain name of the API group will be used.
  • For MARKET, the domain name of the API group allocated by KooGallery will be used.
  • For CONSUMER, the subdomain name of the API group will be used.

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 parameters, with each value being a character string array. Each parameter name must meet the following requirements:

  • Contains letters, digits, periods (.), hyphens (-), or underscores (_).
  • Starts with a letter, with a maximum length of 32 bytes.
  • Case-insensitive and not starts with X-Apig- or X-Sdk-.
  • Case-insensitive and cannot be X-Stage.

header

No

Dictionary

Header parameters, with each value being a character string array. Each parameter name must meet the following requirements:

  • Contains letters, digits, periods (.), and hyphens (-).
  • Starts with a letter, with a maximum length of 32 bytes.
  • Case-insensitive and not starts with X-Apig- or X-Sdk-.
  • Case-insensitive and cannot be X-Stage.
  • Case-insensitive and cannot be X-Auth-Token or Authorization when mode is set to MARKET or CONSUMER.
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:

  • DEVELOPER: debugs the definition of an API that has not been published.
  • MARKET: debugs the definition of an API purchased from KooGallery.
  • CONSUMER: debugs the definition of an API that has been published in a specified environment.
    NOTE:

    In DEVELOPER mode, the API caller must be the API owner.

    In MARKET mode, the API caller must be the API purchaser or owner.

    In CONSUMER mode, the API caller must be the API owner or has authorized its access to apps in the specified environment.

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": [
      "city01",
      "city02"
    ]
  },
  "header": {
    "X-My-City": [
      "city01",
      "city02"
    ]
  }
}

Response

Table 4 Parameter description

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=city01&city=city02 HTTP/1.1\r\nHost: edf94892b11d440795562cb81c5be059.apigw.example.com\r\nUser-Agent: APIGatewayDebugClient/1.0\r\nX-Apig-Mode: debug\r\nX-My-City: city01\r\nX-My-City: city02\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

Table 5 Status codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error