Home > Operation and Maintenance > Linux Operation and Maintenance > How to handle the returned results after calling the interface

How to handle the returned results after calling the interface

坏嘻嘻
Release: 2018-09-19 16:11:14
Original
4494 people have browsed it

This article introduces how to handle the returned results after the interface call, and focuses on the specific steps. The content of this article is very compact, and I hope you will study patiently.

Return results

The returned results are mainly in two formats: XML and JSON. The default is XML. You can specify the public request parameter Format to change the format of the returned results. See Public Parameters for more details. For ease of viewing and aesthetics, the API document return examples are all processed with line breaks and indentation, but the actual return results are not processed with line breaks and indentation.

Normal return example

After the interface is called successfully, the interface return parameters and request ID will be returned. We call such a return a normal return. The HTTP status code is 2xx.

XML example

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

JSON example

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

Exception return example

After an error occurs in the interface call, the error code, error message and request ID will be returned. We call such return an exception return. HTTP status codes are 4xx or 5xx.

You can troubleshoot errors based on interface error codes, public error codes, and API Error Center. When you cannot troubleshoot the error, you can submit a work order to contact us, and indicate the service node HostId and RequestId in the work order.

XML Example

<?xml version="1.0" encoding="UTF-8"?><!--结果的根结点-->
<Error>
    <RequestId>540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx</RequestId> <!--请求 ID-->
    <HostId>ecs.aliyuncs.com</HostId> <!--服务节点-->
    <Code>MissingParameter.CommandId</Code> <!--错误码-->
    <Message>The input parameter “CommandId” that is mandatory for processing this request is not supplied.</Message> <!--错误信息-->
</Error>
Copy after login

JSON Example

{
    "RequestId": "540CFF28-407A-40B5-B6A5-74Bxxxxxxxxx", /* 请求 ID */
    "HostId": "ecs.aliyuncs.com", /* 服务节点 */
    "Code": "MissingParameter.CommandId", /* 错误码 */
    "Message": "The input parameter “CommandId” that is mandatory for processing this request is not supplied." /* 错误信息 */
}
Copy after login

Public Error Code

How to handle the returned results after calling the interface

How to handle the returned results after calling the interface

How to handle the returned results after calling the interface

How to handle the returned results after calling the interface##

The above is the detailed content of How to handle the returned results after calling the interface. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template