How to use Huawei Cloud service APIs with Postman

Feyza Seyrek
Huawei Developers
Published in
6 min readMar 24, 2023
Postman with Huawei Cloud Services

Introduction

Hi 👋😉, in this article I will tell you how to call production APIs of Huawei Cloud services with Postman. Using these APIs, you can integrate services into your own project or create a pipeline process. Enjoyable reading ❗ 🤗☕🍫

As more and more businesses move their operations to the cloud, the demand for cloud services continues to grow. Huawei Cloud is one of the leading cloud service providers in the world, offering a range of cloud-based services for businesses of all sizes. One of the key features of Huawei Cloud is its APIs, which allow developers to integrate their applications with Huawei Cloud services. In this article, we will explore how to use Huawei Cloud service APIs with Postman, a popular tool for testing and debugging APIs. We will cover the steps involved in obtaining an Access Token, configuring Postman, and making API calls to Huawei Cloud services. By the end of this article, you will be ready to start integrating your applications with Huawei Cloud services using Postman.

Postman

To use Huawei Cloud service APIs with Postman, you can follow these steps:

1️⃣ Sign up for a Huawei Cloud account and create an API key for your account. You can do this from the Huawei Cloud console.

2️⃣ Install Postman, if you haven’t already. You can download Postman from the official website.

3️⃣ Open Postman and create a new request by clicking on the “New” button in the top-left corner of the window.

4️⃣ In the request editor, set the HTTP method to the one required by the Huawei Cloud API you want to use (e.g. GET, POST, DELETE).

5️⃣ Enter the URL of the Huawei Cloud API endpoint you want to call in the request URL field. You can find the API endpoint URL in the Huawei Cloud API documentation.

6️⃣ Add any required headers, such as the Authorization header, in the request headers section. You can find the required headers in the Huawei Cloud API documentation.

7️⃣ Add any required parameters, such as query parameters or request body, in the request body or request parameters section. Again, you can find this information in the Huawei Cloud API documentation.

8️⃣ Click the “Send” button to send the request to the Huawei Cloud API endpoint.

9️⃣ Check the response from the API in the “Response” tab. If the response is successful, you should see the data returned by the API in the response body.

🔟 You can save the request and use it again later by clicking on the “Save” button.

Note that some Huawei Cloud APIs may require additional authentication or authorization steps, such as obtaining a token or providing additional credentials. Be sure to follow the API documentation carefully to ensure you are using the API correctly.

Making an API Request with Using Token

You will need to obtain an Access Token to use Huawei Cloud Service APIs with Postman. The Access Token is used to authenticate your requests and provide access to the Huawei Cloud resources that you are authorized to use.

To obtain an Access Token, you will first need to create an API key in the Huawei Cloud console. Once you have created an API key, you can use it to obtain an Access Token by making an API call to the Huawei Cloud IAM API.

To make this API call, you can use Postman and follow these steps:

1️⃣ Create a new Postman request and set the HTTP method to POST.

2️⃣ Enter the URL for the IAM API endpoint that issues Access Tokens. The URL should be in the format: https://iam.{region}.myhuaweicloud.com/v3/auth/tokens, where {region} is the region where your Huawei Cloud account is located.

3️⃣ Add the following headers to the request:

Content-Type: set to application/json

X-Auth-Project-Id: set to the ID of the project you are working with in Huawei Cloud.

Replace your_username, your_password, your_domain_name, and your_project_name with your actual Huawei Cloud account information.

4️⃣ Click on the “Send” button to send the request. The response should include the Access Token that you can use to make API requests.

5️⃣ Copy the Access Token from the response and add it to the Authorization header of your subsequent API requests. Set the value of the Authorization header.

That’s it! You should now be able to use Huawei Cloud Service APIs with Postman using the Access Token you obtained from the IAM API.

For example, to obtain a token in the CN-Hong Kong region, obtain the endpoint of IAM (iam.ap-southeast-1.myhuaweicloud.com) for this region and the resource-path (/v3/auth/tokens) in the URI of the API used to obtain a user token. Then, construct the URI as follows:

https://iam.ap-southeast-1.myhuaweicloud.com/v3/auth/tokens
Token Endpoint on Huawei Cloud

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 endpoints of all APIs in the same region are identical.

Steps:

💠 You can 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. Request Method is POST.

Key: Content-Type

Value: application/json

Headers for Token Endpoint

💠 To get the token, the request body must be in the following format and some fields must be customized.

Request body of Token Endpoint
POST https://iam.ap-southeast-1.myhuaweicloud.com/v3/auth/tokens
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "your_username",
"password": "your_password",
"domain": {
"name": "your_domain_name"
}
}
}
},
"scope": {
"project": {
"name": "your_project_name"
}
}
}
}

Figure : Request body for getting Token

💠 Response of Token API: Your Token information is in the Response Headers. X-Subject-Token is your token.

Creating a Token

Calling ModelArts Service API with Using Token

💥 Firstly, You can write Token information to Request Headers like X-Auth-Token.

Headers of Huawei Cloud Modelarts(AI) Service Url API

💥 For Request Body, “obs_url” is customized as a input parameter and sample obs path is written.

Conclusion 🔚🎉💢

In conclusion, using Huawei Cloud service APIs with Postman is a simple and effective way to integrate your applications with Huawei Cloud services. By following the steps outlined in this article, you can obtain an Access Token, configure Postman, and start making API calls to Huawei Cloud services in no time. Whether you are building a new application from scratch or integrating with an existing system, the flexibility and scalability of Huawei Cloud services combined with the ease of use of Postman make for a powerful combination. So why not give it a try and see how you can leverage the power of Huawei Cloud services in your own applications ❓

References 📜📚

1.Postman

2. Regions and Endpoints

3. API Explorer

API Explorer_Developers-HUAWEI CLOUD

4. Related Recommend Article on Forum:

5. Huawei Cloud Console

--

--