返回结果主要有XML和JSON两种格式,默认为XML,您可以指定公共请求参数 Format
变更返回结果的格式。为了便于查看和美观,API文档返回示例均有换行和缩进处理,实际返回结果无换行和缩进处理。
正常返回示例
API接口调用成功后会返回接口返回参数和请求ID,这样的返回结果称为正常返回结果,HTTP状态码为2xx。
- XML示例
<?xml version="1.0" encoding="UTF-8"?> <!--结果的根结点--> <ActionResponse> <!--返回请求标签--> <RequestId>4C467B38-3910-447D-87BC-AC049166F216</RequestId> <!--返回结果数据--> </ActionResponse>
- JSON示例
{ "RequestId": "4C467B38-3910-447D-87BC-AC049166F216" /* 返回结果数据 */ }
异常返回示例
API接口调用出错后,会返回错误码、错误信息和请求ID,这样的返回结果称为异常返回结果,HTTP状态码为4xx或者5xx。
您可以根据接口错误码,参考VPC API错误中心排查错误。
- XML 示例
<?xml version="1.0" encoding="UTF-8"?><!--结果的根结点--> <Error> <RequestId>540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx</RequestId> <!--请求 ID--> <HostId>vpc.aliyuncs.com</HostId> <!--服务节点--> <Code>MissingParameter.CommandId</Code> <!--错误码--> <Message>The input parameter “CommandId” that is mandatory for processing this request is not supplied.</Message> <!--错误信息--> </Error>
- JSON 示例
{ "RequestId": "540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx", /* 请求 ID */ "HostId": "vpc.aliyuncs.com", /* 服务节点 */ "Code": "MissingParameter.CommandId", /* 错误码 */ "Message": "The input parameter “CommandId” that is mandatory for processing this request is not supplied." /* 错误信息 */ }