Updated on 2026-11-06 GMT+08:00

Making an API Request

This section explains the REST API request structure and describes how to call an API using the API for creating an IAM user as an example.

Request URI

A request URI is in the following format:

{URI-scheme}://{Endpoint}/{resource-path}?{query-string}

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

Table 1 Parameters in a URI

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 between services in different regions. It can be obtained from Endpoints.

For example, The endpoint of IAM in the CN-Hong Kong region is iam.ap-southeast-1.myhuaweicloud.com.

resource-path

Access path of an API for performing a specified operation. You can obtain the path from the URI of the API.

For example, resource-path of the API for creating an IAM user is /v3.0/OS-USER/users.

query-string

Query parameter, which is optional. A question mark (?) must be added before a query parameter. The format is Parameter name=Parameter value.

For example, limit=10 indicates that a maximum of 10 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. The endpoint of the CN-Hong Kong region is iam.cn-north-4.myhuaweicloud.com. iam.ap-southeast-1.myhuaweicloud.com. Find resource-path (/v3.0/OS-USER/users) in the URI of the Creating an IAM User API.

https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users
Figure 1 Example URI

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

The HTTP protocol defines the following request methods that can be used to send a request to the server:

Table 2 HTTP request methods

Method

Description

GET

Requests a server to return specified resources.

PUT

Requests the server to update specified resources.

POST

Requests the server to add resources or perform special operations.

DELETE

Requests the server to delete a specific resource, for example, an object.

HEAD

Requests the server to return the response header.

PATCH

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

Check the URI of the API for creating an IAM user. The request method is POST, and the request is as follows:

POST https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users

Request Header

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

Common request header fields are as follows:

  • 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 are provided for specific APIs, if any.
  • X-Auth-Token: specifies the user token. When token-based authentication is used, this field is mandatory. It is the response to the API used for obtaining a user token through password authentication. This API is the only one that does not require authentication.

For the Creating an IAM User API, the following is an example of the request with headers added when token-based authentication is used:

POST https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users
Content-Type: application/json 
X-Auth-Token: ABCDEFG.... 

Request Body

The request body is usually sent in a structured format, which corresponds to the Content-Type in the request header. The request body contains the content other than the request header. If the request body contains Chinese characters, the character encoding mode in the Content-Type must be set to UTF-8. For example, the request body is Content-Type: application/json; charset=utf-8.

Request bodies vary with APIs. Some APIs do not require a request body, such as the APIs requested using GET and DELETE methods.

You can obtain the request parameters and descriptions from the API request. For details, see Creating an IAM User. The following provides an example request with a body included. Replace the bold fields with the actual values.

  • accountid indicates the ID of the account to which the IAM user belongs.
  • username indicates the IAM username to be created.
  • email indicates the email address of the IAM user.
  • ******** indicates the login password of the IAM user.
POST https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users
Content-Type: application/json 
X-Auth-Token: ABCDEFG....  
 
{ 
     "user": { 
         "domain_id": "accountid", 
         "name": "username", 
         "password": "**********", 
         "email": "email", 
         "description": "IAM User Description" 
     } 
 }

If all data required for the API request is available, you can send the request to call the API through curl, Postman, or coding.