Updated on 2026-01-08 GMT+08:00

Making an API Request

This section describes the structure of a REST API request, and calls the IAM API for obtaining a user token as an example. The obtained token can then be used to authenticate the calling of other APIs.

Request URI

Although a request URI is included in the request header, most programming languages or frameworks require the request URI to be transmitted separately.

A request URI is in the following format: {URI-scheme}://{Endpoint}/{resource-path}?{query-string}

The following table describes the parameters.

Parameter

Description

URI-scheme

Protocol used to transmit requests. All APIs use HTTPS.

Endpoint

Domain name or IP address of the server bearing the REST service. The endpoint varies with services in different regions. It can be obtained from Regions and Endpoints.

resource-path

Access path of an API for performing a specified operation. The path is part of the API URI. For example, resource-path of the API for an administrator to create an IAM user is /v3.0/OS-USER/users.

query-string

(Optional) Query parameter. Ensure that a question mark (?) is included before each query parameter. The parameter format follows "Parameter name=Parameter value". For example, ?limit=10 indicates that a maximum of 10 data records will be displayed.

For example, if you want to create an IAM user, use the endpoint of any region because IAM is a global service.

To simplify the URI display in this document, each API is provided only with a resource path and a request method. The URI-scheme of all APIs is HTTPS, and the endpoints of all APIs in the same region are identical.

Request Methods

HTTP defines the following request methods that can be used to send a request to the server.

Request Method

Description

GET

Request the server to return a specific resource.

PUT

Request the server to update a specific resource.

POST

Request the server to create a new resource or perform a special operation.

DELETE

Request the server to delete a specific resource, such as an object.

HEAD

Request the server to return the response header.

PATCH

Requests the server to update partial contents of a specified resource. If the resource does not exist, a new resource will be created.


  

 

Request Header

You can add additional fields, for example, the fields required by a specified URI or HTTP method, to a request header. For example, to request for the authentication information, add Content-Type, which specifies the request body type.

Common request header fields:

  • Content-Type: specifies the request body type or format. This field is mandatory and its default value is application/json. Other values of this field will be provided for specific APIs if any.
  • Authorization: provides signature authentication information. This field is optional. When AK/SK authentication is enabled, this field is automatically specified for signing the request with SDK. For more information, see AK/SK Authentication.
  • X-Sdk-Date: time when a request is sent. This field is optional. When AK/SK authentication is enabled, this field is automatically specified when SDK is used to sign the request. For more information, see AK/SK Authentication.
  • X-Auth-Token: a user token only for token-based API authentication.
  • X-Project-ID: subproject ID. This field is optional and can be used in multi-project scenarios. The X-Project-ID field is mandatory in the request header for accessing resources in a sub-project through AK/SK authentication.
  • X-Domain-ID: account ID, which is optional. When you call APIs of global services using AK/SK authentication, X-Domain-ID is needed in the request header.

Request Body

A request body is generally sent in structured format. It corresponds to Content-Type in the request header and transfers content except the request header.

The request body varies according to APIs. Certain APIs do not require the request body, such as GET and DELETE.

In the case of the API used to , the request parameters and parameter description can be obtained from the API request. The following provides an example request with a body included. Replace the italic fields in bold with the actual values.

  • Replace username with the actual username.
  • domainname: account to which the user belongs
  • **********: login password of the user
  • xxxxxxxxxx indicates the project name. You can obtain the value from Regions and Endpoints.

The scope parameter specifies where a token takes effect. You can set scope to an account or a project under an account. In the following example, the token takes effect only for the resources in a specified project. For more information about this API, see .

Content-Type: application/json 

{ 
    "auth": { 
        "identity": { 
            "methods": [ 
                "password" 
            ], 
            "password": { 
                "user": { 
                    "name": "username", 
                    "password": "********", 
                    "domain": { 
                        "name": "domainname" 
                    } 
                } 
            } 
        }, 
        "scope": { 
            "project": { 
                "name": "xxxxxxxx" 
            } 
        } 
    } 
}

If all data required by a request is available, you can send the request to call the API through curl, Postman, or coding. In the response to the API used to , x-subject-token is the desired user token. This token can then be used to authenticate the calling of other APIs.