开发者社区 问答 正文

开发指南:返回结果

返回结果主要有 XML 和 JSON 两种格式,默认为 JSON,您可以指定公共请求参数  Format 返回结果的格式。更多详情,请参阅 公共参数
说明:为了便于查看和美观,API 文档返回示例均有换行和缩进等处理,实际返回结果无换行和缩进处理。
[font=PingFangSC, "]

[font=PingFangSC, "]正常返回示例
接口调用成功后会返回接口返回参数和请求 ID,我们称这样的返回为正常返回。HTTP 状态码为 2xx。
XML 示例

<?xml version="1.0" encoding="UTF-8"?> <!--结果的根结点-->
<ActionResponse> <!--返回请求标签-->
    <RequestId>4C467B38-3910-447D-87BC-AC049166F223</RequestId> <!--返回结果数据-->
</ActionResponse>
JSON 示例

{
    "RequestId": "4C467B38-3910-447D-87BC-AC049166F223" /* 返回结果数据 */
}


异常返回示例
接口调用出错后,会返回错误码、错误信息和请求 ID,我们称这样的返回为异常返回。HTTP 状态码为 4xx 或者 5xx。
您可以根据接口错误码以及 公共错误码 排查错误。当您无法排查错误时,可以 提交工单 联系我们,并在工单中注明服务节点 HostId 和 RequestId。
XML 示例

<?xml version="1.0" encoding="UTF-8"?><!--结果的根结点-->
<Error>
    <RequestId>540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx</RequestId> <!--请求 ID-->
    <HostId>ess.aliyuncs.com</HostId> <!--服务节点-->
    <Code>InternalError</Code> <!--错误码-->
    <Message>The request processing has failed due to some unknown error, exception or failure.</Message> <!--错误信息-->
</Error>

JSON 示例

{
    "RequestId": "540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx", /* 请求 ID */
    "HostId": "ess.aliyuncs.com", /* 服务节点 */
    "Code": "InternalError", /* 错误码 */
    "Message": "The request processing has failed due to some unknown error, exception or failure." /* 错误信息 */
}




公共错误码

错误代码错误信息HTTP 状态码说明
InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.400指定的 AccessKey 不存在。
InvalidParameterThe specified value of parameter <parameter name> is not valid.400指定的参数取值不合法。
MissingParameterThe input parameter <parameter name> that is mandatory for processing this request is not supplied400缺少必需参数。
NoSuchVersionThe specified version does not exist.400指定的 API 版本不存在。
ResourceNotAvailableResource you requested is not available in this region or zone.400指定的地域暂未部署弹性伸缩服务。
ThrottlingRequest was denied due to request throttling.400系统流控期间,请稍后再试。
UnsupportedOperationThe specified action is not supported.400无法调用指定的 API。
ForbiddenUsers are not authorized to operate on the specified resource.403您无法执行该操作。
Forbidden.RiskControlThis operation is forbidden by Aliyun Risk Control system.403系统风险控制,禁止该操作。
Forbidden.UnsubscribedDo not have permission to access this API.403您未开通弹性伸缩服务,无法调用该 API。
Forbidden.UserVerificationYour user account is not verified by Aliyun.403您未完成实名认证。更多详情,请参阅 账号实名认证相关文档
SignatureDoesNotMatchThe signature we calculated does not match the one you provided.403我们计算得出的签名与您提供的签名不匹配。
InternalErrorThe request processing has failed due to some unknown error, exception or failure.500系统错误。
ServiceUnavailableThe request has failed due to a temporary failure of the server.503服务器当前无法处理请求,请稍后再试。

展开
收起
青蛙跳 2018-08-17 13:20:53 1100 分享 版权
阿里云 AI 助理回答

返回结果支持两种主要格式:XML 和 JSON,默认采用 JSON 格式。您可以通过设置公共请求参数 Format 来指定响应的格式。

正常返回示例中,当接口调用成功后,HTTP 状态码为 2xx,会返回接口执行的具体参数及一个唯一的请求 ID,例如:

  • XML 示例:

    <?xml version="1.0" encoding="UTF-8"?>
    <ActionResponse>
    <RequestId>4C467B38-3910-447D-87BC-AC049166F223</RequestId>
    </ActionResponse>
    
  • JSON 示例:

    {
    "RequestId": "4C467B38-3910-447D-87BC-AC049166F223"
    }
    

异常返回示例中,如果接口调用出错,HTTP 状态码将为 4xx 或 5xx,并包含错误码、错误信息和请求 ID,例如:

  • XML 异常示例:

    <?xml version="1.0" encoding="UTF-8"?>
    <Error>
    <RequestId>540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx</RequestId>
    <HostId>ess.aliyuncs.com</HostId>
    <Code>InternalError</Code>
    <Message>The request processing has failed due to some unknown error, exception or failure.</Message>
    </Error>
    
  • JSON 异常示例:

    {
    "RequestId": "540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx",
    "HostId": "ess.aliyuncs.com",
    "Code": "InternalError",
    "Message": "The request processing has failed due to some unknown error, exception or failure."
    }
    

针对不同的错误情况,系统定义了一系列公共错误码,如 InvalidAccessKeyId.NotFound 表示 AccessKey 不存在(HTTP 400),Forbidden 表示无权限执行操作(HTTP 403),以及 InternalError 表示系统内部错误(HTTP 500)等。这些错误码有助于定位问题原因并进行相应处理。

在遇到问题时,首先根据返回的错误码对照公共错误码文档进行排查。若无法自行解决,可提交工单并提供 HostId 和 RequestId 以便获取进一步帮助。

请注意,API 文档中的示例为了便于阅读进行了格式化,实际返回数据不会包含换行和缩进。

参考资料: 返回结果与格式设置说明
正常与异常返回示例
公共错误码列表

有帮助
无帮助
AI 助理回答生成答案可能存在不准确,仅供参考
0 条回答
写回答
取消 提交回答