开发者社区> 问答> 正文

API 服务的返回结果是什么


调用 API 服务后返回数据采用统一格式:

  • 返回的 HTTP 状态码为 2xx,代表调用成功。
  • 返回的 HTTP 状态码为 4xx 或 5xx,代表调用失败。

调用成功返回的数据格式主要有 XML 和 JSON 两种,外部系统可以在请求时传入参数来制定返回的数据格式,默认为 XML 格式。

本文档中的返回示例为了便于用户查看,做了格式化处理,实际返回结果是没有进行换行、缩进等处理的。


成功结果


XML示例:
<?xml version="1.0" encoding="UTF-8"?><!--结果的根结点--><接口名称+Response><!--返回请求标签--><RequestId>4C467B38-3910-447D-87BC-AC049166F216</RequestId><!--返回结果数据--></接口名称+Response>

JSON示例:{"RequestId": "4C467B38-3910-447D-87BC-AC049166F216",/* 返回结果数据 */}


错误结果


调用接口出错后,将不会返回结果数据。调用方可根据每个接口对应的错误码以及下述 公共错误码 来定位错误原因。 当调用出错时,HTTP 请求返回一个 4xx 或 5xx 的 HTTP 状态码。返回的消息体中是具体的错误代码及错误信息。另外还包含一个全局唯一的请求 ID:RequestId 和一个您该次请求访问的站点 ID:HostId。在调用方找不到错误原因时,可以联系阿里云客服,并提供该 HostId 和 RequestId,以便我们尽快帮您解决问题。

XML示例:
<?xml version="1.0" encoding="UTF-8"?><Error><RequestId>8906582E-6722-409A-A6C4-0E7863B733A5</RequestId><HostId>ecs.aliyuncs.com</HostId><Code>InvalidOwnerId</Code><Message>The specified OwnerId is not valid.</Message></Error>

JSON示例:
{"RequestId": "8906582E-6722-409A-A6C4-0E7863B733A5","HostId": "ecs.aliyuncs.com","Code": "InvalidOwnerId","Message": "The specified OwnerId is not valid."}

公共错误码

错误代码HTTP 状态码描述
IdempotentParameterMismatch400The request is retried with updated parameters.
IllegalTimestamp400The input parameter “Timestamp” that is mandatory for processing this request is not supplied.
IncompleteSignature400The request signature does not conform to Aliyun standards.
InsufficientBalance400Your account does not have enough balance.
InvalidAccessKeyId.NotFound400The specified Access Key ID does not exist.
InvalidOwner400OwnerId and OwnerAccount can’t be used at one API access.
InvalidOwnerAccount400The specified OwnerAccount is not valid.
InvalidOwnerId400The specified OwnerId is not valid.
InvalidParamater400The specified parameter “SignatureMethod” is not valid.
InvalidParamater400The specified parameter “SignatureVersion” is not valid.
InvalidParameter400The specified parameter is not valid
InvalidParameter400The specified parameter “Action or Version” is not valid.
InvalidParameter.IsNull400The required parameter must be not null.
MissingParameter400The input parameter “Action” that is mandatory for processing this request is not supplied
MissingParameter400The input parameter “AccessKeyId” that is mandatory for processing this request is not supplied
MissingParameter400The input parameter “Signature” that is mandatory for processing the request is not supplied.
MissingParameter400The input parameter “TimeStamp” that is mandatory for processing this request is not supplied
MissingParameter400The input parameter “Version” that is mandatory for processing this request is not supplied
SignatureNonceUsed400The request signature nonce has been used.
Throttling400You have made too many requests within a short time; your request is denied due to request throttling.
UnsupportedParameter400
ChargeTypeViolation403The operation is not permitted due to charge type of the instance.
Forbidden.AccessKeyDisabled403The Access Key is disabled.
Forbidden.NotSupportRAM403This action does not support accessed by RAM mode.
Forbidden.RAM403User not authorized to operate on the specified resource, or this API doesn't support RAM.
Forbidden.RiskControl403This operation is forbidden by Aliyun RiskControl system.
Forbidden.SubUser403The specified action is not available for you.
Forbidden.Unauthorized403User not authorized to operate on the specified resource.
InvalidAccount.NotFound403The specified Account does not exist.
InvalidAction403Specified action is not valid.
InvalidIdempotenceParameter.Mismatch403The specified parameters are different from before.
InvalidParameter.OwnerAccount403OwnerAccount is Invalid.
InvalidParameter.ResourceOwnerAccount403ResourceOwnerAccount is Invalid.
LastTokenProcessing403The last token request is processing.
MissingParameter403The input parameter OwnerId,OwnerAccount that is mandatory for processing this request is not supplied.
RealNameAuthenticationError403Your account has not passed the real-name authentication yet.
UnsupportedHTTPMethod403This http method is not supported.
InvalidDiskId.NotFound404The specified DiskId does not exist.
InvalidImageId.NotFound404The specified ImageId does not exist.
InvalidInstanceId.NotFound404The specified InstanceId does not exist.
InvalidRegionId.NotFound404The specified RegionId does not exist.
InvalidSecurityGroupId.NotFound404The specified SecurityGroupId does not exist.
InvalidSnapshotId.NotFound404The specified SnapshotId does not exist.
OperationConflict409Request was denied due to conflict with a previous request.
InternalError500The request processing has failed due to some unknown error, exception or failure.
ServiceUnavailable503The request has failed due to a temporary failure of the server.
[tr=rgb(239, 251, 255)][td]ServiceUnavailable.RegionMaintaining 503System maintenance is in progress on the selected region, please wait a few minutes before trying again.

展开
收起
boxti 2017-10-19 11:37:36 3827 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
CUDA MATH API 立即下载
API PLAYBOOK 立即下载
传统企业的“+互联网”-API服务在京东方的实践 立即下载