El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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
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

Debugging Using Postman

Updated on 2024-11-04 GMT+08:00

Overview

Postman is a visual editing tool for building and testing API requests. It provides an easy-to-use UI to send HTTP requests, including GET, PUT, POST, and DELETE requests, and modify parameters in HTTP requests. Postman also returns response to your requests.

To fully understand APIs, refer to API Reference on the Application Side. The Postman Collection is already available, in which the structure of API call requests are ready for use.

This topic uses Postman as an example to describe how to debug the following APIs when the application simulator connects to the IoT platform using HTTPS:

Prerequisites

Installing and Configuring Postman

  1. Install Postman.

    1. Visit the Postman website, and download and install the latest version of Postman (64-bit) for Windows.
      NOTE:
    2. Enter the email address, username, and password to register Postman.

  2. Import the Postman environment variables.

    1. Click in the upper right corner to open the MANAGE ENVIRONMENTS window.

    2. Click Import. On the page displayed, click Select File to import the IoTDA.postman_environment.json file (obtained after the Collection package is decompressed).

    3. Click the IoTDA environment imported.

    4. Configure parameters based on the following table.

      Parameter

      Description

      IAMEndpoint

      IAM endpoint. For details, see Regions and Endpoints.

      IoTDAEndpoint

      IoTDA endpoint. For details, see 2.e.

      IAMUserName

      IAM username, which can be obtained from the My Credentials page.

      IAMPassword

      Password for logging in to Huawei Cloud.

      IAMDoaminId

      Account name, which can be obtained from the My Credentials page.

      region

      Region where IoTDA is enabled.

    5. Obtain IoTDA endpoints.
      Log in to the console. In the navigation pane, choose Overview. Click Access Details in the Instance Information area. Select the access address based on the access type and protocol.
      Figure 1 Obtaining access information
    6. Return to the home page and set the environment variable to the imported IoTDA.

  3. Click Import in the upper left corner and click Choose Files to import the API call (V5).postman_collection.json file.

    After the file is uploaded, the dialog box shown in the following figure is displayed.

Debugging the API Obtaining the Token for an IAM User

Before using platform APIs, an application must call the API Obtaining the Token of an IAM User for authentication. After the authentication is successful, Huawei Cloud returns X-Subject-Token.

To call this API, the application constructs an HTTP request. An example request is as follows:

POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens 
Content-Type: application/json 

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

Debug the API by following the instructions provided in Obtaining the Token of an IAM User.

  1. Configure the HTTP method, URL, and headers of the API.

  2. Configure the body of the API.

  3. Click Send. The returned code and response are displayed in the lower part of the page.

  4. Use the returned X-Subject-Token value in the header field to update X-Auth-Token in the IoTDA environment so that it can be used in other API calls. If the token expires, the Authentication API must be called again to obtain a new token.

    The X-Auth-Token parameter is automatically updated in Postman. You do not need to manually update it.

Debugging the API Listing Projects Accessible to an IAM User

Before accessing platform APIs, the application must call the API Listing Projects Accessible to an IAM User to obtain the project ID of the user.

To call this API, the application constructs an HTTP request. An example request is as follows:

GET https://iam.cn-north-4.myhuaweicloud.com/v3/auth/projects
Content-Type: application/json
X-Auth-Token: ********

Debug the API by following the instructions provided in Listing Projects Accessible to an IAM User.

  1. Configure the HTTP method, URL, and headers of the API.

  2. Click Send. The returned code and response are displayed in the lower part of the page.

  3. The returned body contains a list of projects. Search for the item whose name is the same as the value of region in the IoTDA environment, and use the id value to update project_id in the IoTDA environment so that it can be used in other API calls.

    In this example, the project_id parameter is automatically updated in Postman. You do not need to manually update it.

Debugging the API Creating a Product

Before connecting a device to the platform, an application must call the API Creating a Product. The product created will be used during device registration.

To call this API, the application constructs an HTTP request. An example request is as follows:

POST https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/products
Content-Type: application/json
X-Auth-Token: ********

{
  "name" : "Thermometer",
  "device_type" : "Thermometer",
  "protocol_type" : "MQTT",
  "data_format" : "binary",
  "manufacturer_name" : "ABC",
  "industry" : "smartCity",
  "description" : "this is a thermometer produced by Huawei",
  "service_capabilities" : [ {
    "service_type" : "temperature",
    "service_id" : "temperature",
    "description" : "temperature",
    "properties" : [ {
      "unit" : "centigrade",
      "min" : "1",
      "method" : "R",
      "max" : "100",
      "data_type" : "decimal",
      "description" : "force",
      "step" : 0.1,
      "enum_list" : [ "string" ],
      "required" : true,
      "property_name" : "temperature",
      "max_length" : 100
    } ],
    "commands" : [ {
      "command_name" : "reboot",
      "responses" : [ {
        "response_name" : "ACK",
        "paras" : [ {
          "unit" : "km/h",
          "min" : "1",
          "max" : "100",
          "para_name" : "force",
          "data_type" : "string",
          "description" : "force",
          "step" : 0.1,
          "enum_list" : [ "string" ],
          "required" : false,
          "max_length" : 100
        } ]
      } ],
      "paras" : [ {
        "unit" : "km/h",
        "min" : "1",
        "max" : "100",
        "para_name" : "force",
        "data_type" : "string",
        "description" : "force",
        "step" : 0.1,
        "enum_list" : [ "string" ],
        "required" : false,
        "max_length" : 100
      } ]
    } ],
    "option" : "Mandatory"
  } ],
  "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka"
}

Debug the API by following the instructions provided in Creating a Product.

Note: Only the parameters used in the debugging example are described in the following steps.

  1. Configure the HTTP method, URL, and headers of the API.

  2. Configure the body of the API.

  3. Click Send. The returned code and response are displayed in the lower part of the page.

  4. Use the returned product_id value to update the product_id parameter in the IoTDA environment so that it can be used in other API calls.

    Note: The product_id parameter is automatically updated in Postman. You do not need to manually update it.

Debugging the API Querying a Product

An application can call the API Querying a Product to query details about a product.

To call this API, the application constructs an HTTP request. An example request is as follows:

GET https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/products/{product_id}
Content-Type: application/json
X-Auth-Token: ********

Debug the API by following the instructions provided in Querying a Product.

Note: Only the parameters used in the debugging example are described in the following steps.

  1. Configure the HTTP method, URL, and headers of the API.

  2. Click Send. The returned code and response are displayed in the lower part of the page.

Debugging the API Creating a Device

Before connecting a device to the platform, an application must call the API Registering a Device. Then, the device can use the unique identification code to get authenticated and connect to the platform.

To call this API, the application constructs an HTTP request. An example request is as follows:

POST https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/devices
Content-Type: application/json
X-Auth-Token: ********

{
  "node_id" : "ABC123456789",
  "device_name" : "dianadevice",
  "product_id" : "b640f4c203b7910fc3cbd446ed437cbd",
  "auth_info" : {
    "auth_type" : "SECRET",
    "secure_access" : true,
    "fingerprint" : "********",
    "secret" : "********",
    "timeout" : 300
  },
  "description" : "watermeter device"
}

Debug the API by following the instructions provided in Creating a Device.

Note: Only the parameters used in the debugging example are described in the following steps.

  1. Configure the HTTP method, URL, and headers of the API.

  2. Configure the body of the API.

  3. Click Send. The returned code and response are displayed in the lower part of the page.

  4. Use the returned device_id value to update the device_id parameter in the IoTDA environment so that it can be used in other API calls.

    Note: The device_id parameter is automatically updated in Postman. You do not need to manually update it.

Debugging the API Querying a Device

An application can call the API Querying a Device to query details about a device registered with the platform.

To call this API, the application constructs an HTTP request. An example request is as follows:

GET https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/devices/{device_id}
Content-Type: application/json
X-Auth-Token: ********

Debug the API by following the instructions provided in Querying a Device.

Note: Only the parameters used in the debugging example are described in the following steps.

  1. Configure the HTTP method, URL, and headers of the API.

  2. Click Send. The returned code and response are displayed in the lower part of the page.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback