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

Making an API Request

Updated on 2024-12-30 GMT+08:00

This section describes the structure of an API request, and uses the OneAccess API for login with a username and password as an example to demonstrate how to call an API. After successful request, the obtained session_token can then be used to obtain user information.

Prerequisites

Before calling APIs, obtain the ClientId of added applications in the administrator portal from Basic Information.

Request URI

A request URI is in the following format:

{URI-scheme} :// {domain_name} / {resource-path}

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

  • URI-scheme: Protocol used to transmit requests. All APIs use HTTPS.
  • domain_name: User access domain name that you must specify when you call a OneAccess API. For details about how to obtain the domain name, see Obtaining the User Access Domain Name.
  • resource-path: Access path of an API for performing a specified operation. Obtain the path from the URI of an API. For example, the resource-path of the API used to log in with a username and password is /api/v2/sdk/login.

For example, to obtain a session_token for the domain name abcdefg.huaweioneaccess.com, provide this domain name and obtain the resource-path (/api/v2/sdk/login) in the URI of the API used to obtain a session_token. Then, construct the URI as follows:

https://abcdefg.huaweioneaccess.com/api/v2/sdk/login
Figure 1 Example URI
NOTE:

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 domain_name values of all APIs in the same instance are identical.

Request Methods

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

  • GET: requests the 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 specified resources, for example, an object.
  • HEAD: requests the server to return the response header only.
  • PATCH: requests the server to update partial content of a specified resource. If the resource does not exist, a new resource will be created.

For example, in the case of the API used to log in with a username and password, the request method is POST. The request is as follows:

POST https://abcdefg.huaweioneaccess.com/api/v2/sdk/login

Request Header

You can also add additional fields to a request, such as the fields required by a specified URI or HTTP method. For example, fields that indicate user agent information and application ID.

Table 1 lists the common request header fields.
Table 1 Common request header fields

Name

Description

Mandatory

Example

X-operating-sys-version

OS version of the caller.

Yes

Android 10

X-device-fingerprint

Device fingerprint of the caller.

Yes

156aysdna213sc50

X-device-ip

Caller IP address.

No

10.10.10.1

X-agent

User agent information.

Yes

Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36

X-L

Language type.

No

zh

X-client-id

Application ID, which is a ClientId allocated to an application after registration.

Yes

DRrYIqauawN0I8myTMoDTPys6ezGZxnm

X-tenant-id

Tenant ID. This parameter is mandatory for ISV applications.

No

08f770f51f80d2f40f38c00cb199fd20

X-signature

Signature information, which is used to determine the user login status. This parameter is not required for all APIs. For details about how to construct the signature, see Signing a Session Token.

No

D0JeOUuVqU8Ixvl0xrmewQRk4AuGZrtk1RfBxueNKUrNPpgSbXrYnzw...

An example request for calling the API used to log in with a username and password is as follows:

POST https://abcdefg.huaweioneaccess.com/api/v2/sdk/login
X-operating-sys-version: Android 10
X-device-fingerprint: 156aysdna213sac
X-device-ip: 10.10.10.1
X-agent: Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36
X-L: zh
X-client-id: DRrYIqauawN0I8myTMoDTPys6ezGZxnm
X-tenant-id: 08f770f51f80d2f40f38c00cb199fd21

(Optional) Request Body

The body of a request is often sent in a structured format (for example, JSON or XML) to transfer content except the request header.

The request body varies between APIs. Some APIs do not require the request body, such as the APIs requested using the GET and DELETE methods.

In the case of the API used to log in with a username and password, the request parameters and parameter description can be obtained from the API request. The following provides an example request with a body included. Replace UserName and Password with the actual username and password, respectively.

POST https://abcdefg.huaweioneaccess.com/api/v2/sdk/login
X-operating-sys-version: Android 10
X-device-fingerprint: 156aysdna213sac
X-device-ip: 10.10.10.1
X-agent: Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36
X-L: zh
X-client-id: DRrYIqauawN0I8myTMoDTPys6ezGZxnm
X-tenant-id: 08f770f51f80d2f40f38c00cb199fd21

{
  "user_name": "UserName",
  "password": "PassWord"
}

If all data required for the API 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 log in with a username and password, session_token is the credential indicating successful login. This session_token can then be used to obtain user information.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback