Learn how to debug Alibaba Cloud API operations online in OpenAPI Explorer.
Create an Alibaba Cloud account
API calls require an Alibaba Cloud account. If you don't have one, register on the Alibaba Cloud official website.
Activate Alibaba Cloud services
Activate the Alibaba Cloud services that you want to use. The following example uses SMS:
-
Go to User Center, search for Short Message Service, and click Activate.
-
Go to the service console, such as the SMS console, and click Activate.
You must activate an Alibaba Cloud service before calling its API operations.
Debug an API operation online
Sign in to OpenAPI Explorer, select an activated Alibaba Cloud service, such as ECS, and then click Debug.
Select the API operation to debug, such as DescribeInstanceTypeFamilies for ECS. In the Parameters section, enter values as described on the Document tab, then click Initiate Call. OpenAPI online debugging.
Response
The Response tab shows the HTTP status code and data returned by the call.
This tab also shows Request Header and Response Header information.
Successful call
A successful call returns HTTP status code 200 with a JSON response. Each parameter is described in the API documentation, such as the DescribeInstanceTypeFamilies reference.
Failed call
A failed call returns an HTTP status code in the 4xx range. Alibaba Cloud APIs use a unified error response structure, except for a few services that do not use the standard gateway. The following example shows the error format for the RunInstances operation of ECS:
{
"RequestId": "7DC0013A-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Message": "The specified endpoint cant operate this region. Please use API DescribeRegions to get the appropriate endpoint, or upgrade your SDK to latest version.(from POP)",
"Recommend": "https://api.aliyun.com/troubleshoot?q=InvalidOperation.NotSupportedEndpoint&product=Ecs&requestId=7DC0013A-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"HostId": "ecs-cn-hangzhou.aliyuncs.com",
"Code": "InvalidOperation.NotSupportedEndpoint"
}
|
Parameter |
Description |
|
RequestId |
The globally unique request ID. Provide this |
|
HostId |
The service endpoint where the error occurred. In this example, it is the ECS endpoint in the China (Hangzhou) region. |
|
Code |
A short identifier for the error type. Look up this code in Alibaba Cloud documentation for solutions. In this example, the endpoint does not support the target region. |
|
Message |
The detailed error message. In this example, the endpoint does not support the selected region. Use the |
|
Recommend |
A diagnostic URL. Open this link to visit OpenAPI Troubleshoot for solutions. |
To troubleshoot errors, use OpenAPI Troubleshoot.
SDK sample code
On the SDK sample code tab, select an SDK version and language, then click Run Example.
You can also click View Version Differences to compare SDK versions, Download Full Project to download the code, or toggle Generate Example in Common Mode to switch the generation mode.
CLI example
Call history
The Call History tab lists your past API calls. Review parameters and click Redebug to rerun a call. If a call's status is failed, use Diagnose to identify the cause.
On the CLI example tab, click the run button to debug the command online.
Error codes
The Error Codes tab lists potential errors and their descriptions. Click Diagnose to open the diagnosis page, which provides relevant documents, forum discussions, and support.
For example, entering an invalid RegionId returns HTTP status code 404, error code InvalidRegionId.NotFound, and the message The RegionId provided does not exist in our records..