Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Request

Updated on 2025-02-06 GMT+08:00

This section describes the structure of a REST API request, and uses the IAM API for creating an IAM user as an administrator as an example to demonstrate how to call an API. The user token obtained by this API can then be used to authenticate the calling of other APIs.

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 separately transmitted.

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.

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

resource-path

Resource path of an API. Obtain the path from the URI of an API. For example, the resource-path of the API for obtaining a user token is /v3/auth/tokens.

query-string

(Optional) Query parameter. Ensure that a question mark (?) is included in front of each query parameter, which is in the format of Parameter name=Parameter value. For example, ?limit=10 indicates that a maximum of 10 data records can be queried.

For example, to create an IAM user, obtain and combine the endpoint of any region (for example, iam.ap-southeast-1.myhuaweicloud.com of the CN-Hong Kong region) and the resource-path (/v3.0/OS-USER/users) in the URI of the API used to create an IAM user as an administrator. The resulting URI is as follows:

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

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

Request Methods

The HTTP protocol defines the following request methods for sending requests to a server.

Table 2 HTTP methods

Method

Description

GET

Requests a server to return specified resources.

PUT

Requests a server to update specified resources.

POST

Requests a server to add resources or perform special operations.

DELETE

Requests a server to delete a specified resource (for example, an object).

HEAD

Requests resource headers from a server.

PATCH

Requests a server to update part of specified resources.

If the requested resource does not exist, the server may create a resource using the PATCH method.

For example, in the URI used to create an IAM user as an administrator, the request method is POST. The request is as follows:
POST https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users
Content-Type: application/json
X-Sdk-Date: 20240416T095341Z
Authorization: SDK-HMAC-SHA256 Access=****************, SignedHeaders=content-type;host;x-sdk-date, Signature=****************

Request Header

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

For details about common request headers, see Table 3.

Table 3 Common fields in request headers

Parameter

Description

Mandatory

Example

Host

Specifies the server to which a request is sent, which can be obtained from the URL of the service API. The value is in the format of Host name:Port number. If the port number is not specified, the default port is used. The default port number for https is 443.

No

This field is mandatory for access key (AK)/secret access key (SK) authentication.

code.test.com

or

code.test.com:443

Content-Type

Specifies the type (or format) of a message body. The default value application/json is recommended. Other values will be described in the specific APIs.

Yes

application/json

Content-Length

Specifies the length of a request body, in bytes.

No

3495

X-Project-Id

Specifies a project ID. You can obtain the project ID by referring to Obtaining the Project ID.

No

This field is mandatory for requests that use AK/SK authentication in the Dedicated Cloud (DeC) scenario or multi-project scenario.

e9993fc7************baa340f9c0f4

X-Auth-Token

Specifies a user token.

A user token is carried in a response to the API for obtaining a user token. This API is the only one that does not require authentication.

The value of X-Subject-Token in the response header is the token.

No

This field is mandatory for token authentication.

The following is part of an example token:

MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ

NOTE:

APIs also support AK/SK authentication, which uses SDKs to sign a request. During the signature, the Authorization (signature authentication) and X-Sdk-Date (time when a request is sent) headers are automatically added to the request.

For details about AK/SK authentication, see Authentication.

When the API used to create an IAM user as an administrator uses AK/SK authentication, the request with the header added is as follows:
POST https://iam.ap-southeast-1.myhuaweicloud.com/v3.0/OS-USER/users
Content-Type: application/json
X-Sdk-Date: 20240416T095341Z
Authorization: SDK-HMAC-SHA256 Access=****************, SignedHeaders=content-type;host;x-sdk-date, Signature=****************

Request Body

This part is optional. A request body is generally sent in a structured format (for example, JSON or XML), which is specified by Content-Type in the request header. It is used to transfer content other than the request header. If the request body contains full-width characters, these characters must be coded in UTF-8.

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

For the API used to create an IAM user as an administrator, you can obtain the request parameters and parameter description from the API request. The following provides an example request with a body included. Replace the values in bold with the actual ones.

  • accountid is the ID of the account to which an IAM user belongs.
  • username is the IAM username to be created.
  • email is the email address of the IAM user.
  • ********** is 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-Sdk-Date: 20240416T095341Z
Authorization: SDK-HMAC-SHA256 Access=****************, SignedHeaders=content-type;host;x-sdk-date, Signature=****************

{
     "user": {
         "domain_id": "accountid",
         "name": "username",
         "password": "**********",
         "email": "email",
         "description": "IAM User Description"
     }
 }

If all data required by an API request is available, you can send the request to call the API through curl, Postman, or coding. In the response to the API for obtaining a user token, x-subject-token carries a user token. You can use this token to authenticate the calling of other APIs.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback