1
0
forked from docs/doc-exports
doc-exports/docs/vpn/api-ref/vpn_api_0011.html
Hongwei, King Wang 32c06a10a2 vpn_api
Reviewed-by: Sarda, Priya <prsarda@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-authored-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
Co-committed-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
2024-08-15 14:18:28 +00:00

6.8 KiB

Response

Status Code

After sending a request, you can receive a response, including a status code, response header, and response body.

A status code is a group of digits, ranging from 1xx to 5xx. It indicates the status of a response. For more information, see Status Codes.

For example, if status code 201 is returned after you call the API for obtaining a user token, the request is successful.

Response Header

Like a request, a response also has a header, for example, Content-Type.

Figure 1 shows the response header for the API used to obtain a user token. The x-subject-token field carries a user token. You can use this token to authenticate the calling of other APIs.

Figure 1 Response header for the API used to obtain a user token

Response Body

This part is optional. A response body is generally returned in a structured format (for example, JSON or XML), which is specified by Content-Type in the response header. It is used to transfer content other than the response header.

The following is part of a response body for the API used to obtain a user token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "token": {
        "expires_at": "2022-09-10T06:52:13.855000Z",
        "methods": [
            "password"
        ],
        "catalog": [
            {
                "endpoints": [
                    {
......

If an error occurs during API calling, an error code and an error message will be displayed. The following is an example of an error response body.

1
2
3
4
{
    "error_msg": "The format of message is error",
    "error_code": "AS.0001"
}

error_code specifies an error code, and error_msg describes the error.