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

Creating a Batch Task

Updated on 2022-02-24 GMT+08:00

Typical Scenario

When an NA needs to perform an operation on a batch of devices, the NA can call this API to create a batch task. Currently, the supported batch operations include delivering pending commands to devices in batches.

API Function

This API is used by an NA to create a batch task for devices on the IoT platform.

API Prototype

Method

POST

URL

https://server:port/iocm/app/batchtask/v1.1.0/tasks

Transport Protocol

HTTPS

Request Parameters

Parameter

Mandatory or Optional

Type

Location

Description

app_key

Mandatory

String

header

Identifies an application that can be accessed on the IoT platform. The value of this parameter is allocated by the IoT platform when the application is created on the platform.

Authorization

Mandatory

String

header

Indicates the authentication information for accessing the IoT platform. The value is Bearer {accessToken}, in which {accessToken} indicates the access token returned by the Authentication API.

appId

Mandatory

String(64)

body

Identifies an application that can be accessed on the IoT platform. The value of this parameter is allocated by the IoT platform when the application is created on the platform. Set this parameter to the value of appId of the authorized application.

param

Mandatory

ObjectNode

body

Indicates the task parameter, which varies depending on the value of taskType.

taskName

Mandatory

String

body

Indicates the task name. The value is a string of a maximum of 256 characters.

taskType

Mandatory

String

body

Indicates the task type. The values include DeviceCmd.

timeout

Mandatory

Integer

body

Indicates the timeout duration of a task, in minutes. The value range is 10–2880.

tags

Optional

List<TagDTO2>

body

Indicates the tag list.

ObjectNode structure

Parameter

Mandatory or Optional

Type

Location

Description

type

mandatory

String

body

Indicates the batch command type. The options include DeviceList, DeviceType, DeviceArea, GroupList, Broadcast, and GroupIdList.

deviceList

Conditionally mandatory

List<String>

body

Indicates the device ID list. This parameter is mandatory when type is set to DeviceList.

deviceType

Conditionally mandatory

String

body

Indicates the device type. This parameter is mandatory when type is set to DeviceType. The value must be the same as that defined in the profile file.

manufacturerId

Conditionally optional

String

body

Identifies a manufacturer. This parameter is mandatory when type is set to DeviceType. The value must be the same as that defined in the profile file.

model

Conditionally optional

String

body

Indicates the model of the device. This parameter is mandatory when type is set to DeviceType. The value must be the same as that defined in the profile file.

deviceLocation

Conditionally mandatory

String

body

Indicates the location of the device. This parameter is mandatory when type is set to DeviceArea.

groupList

Conditionally mandatory

List<String>

body

Indicates the group ID list or device group name list. When type is set to GroupIdList, set this parameter to the group ID. When type is set to GroupList, set this parameter to the device group name.

command

mandatory

CommandDTO

body

Indicates the command information.

callbackUrl

optional

String

body

Indicates the push address of the command execution result.

maxRetransmit

optional

Integer(0-3)

body

Indicates the maximum number of retransmissions of a command. The value ranges from 0 to 3.

groupTag

optional

String

body

Indicates the group tag.

CommandDTO structure

Parameter

Mandatory or Optional

Type

Location

Description

serviceId

Mandatory

String(1-64)

body

Identifies the service corresponding to the command. The value of this parameter must be the same as the value of serviceId defined in the profile file.

method

Mandatory

String(1-128)

body

Indicates the name of a specific command under the service. The value of this parameter must be the same as the command name defined in the profile file.

paras

Optional

ObjectNode

body

Indicates a command parameter in the jsonString format. The value consists of key-value pairs. Each key is the paraName parameter in commands in the profile file. The specific format depends on the application and device.

TagDTO2 structure

Parameter

Mandatory or Optional

Type

Location

Description

tagName

Mandatory

String(1-128)

body

Indicates the tag name.

tagValue

Mandatory

String(1-1024)

body

Indicates the tag value.

Response Parameters

Status Code: 200 OK

Parameter

Type

Description

taskID

String

Identifies a batch task.

Request Example

Method: POST
Request:
https://server:port/iocm/app/batchtask/v1.1.0/tasks
Header:
app_key: ******
Authorization: Bearer ******
Content-Type: application/json
Body:
{
  "appId": "******",
  "timeout": 1000,
  "taskName": "******",
  "taskType": "DeviceCmd",
  "param": {
    "type": "******",
    "deviceList": [
      "********",
      "********",
      "********"
    ],
    "command": {
      "serviceId": "********",
      "method": "********",
      "paras": {
        "paraName1": "paraValue1",
        "paraName2": "paraValue2"
      }
    }

  }
}

Response Example

Response:
Status Code: 200 OK
Content-Type: application/json
Body:
{
  "taskID": "******"
}

Error Codes

HTTP Status Code

Error Code

Error Description

Remarks

200

100203

The application is not existed.

The application does not exist.

Recommended handling:

  • Check whether appId carried in the HTTP request header is correct.
  • Check whether appId in the request path (URL) is correct.

200

101001

Resource doesn't exist.

The resource does not exist.

200

105001

The batchTask count has reached the limit.

If the number of unfinished tasks is greater than or equal to 10, a message is returned, indicating that the number of tasks reaches the limit.

200

105002

The batchTask name has exist.

The task name exists.

Recommended handling: Change the task name.

400

105201

The tagName and tagValue has been used on the platform.

The tagName and tagValue have been used on the IoT platform.

400

50400

The input is invalid.

An input parameter is invalid.

Recommended handling: Check whether parameters carried in the API call request are valid.

401

100028

The user has no right.

The user has no operation permission.

403

100203

The application is not existed.

The application does not exist.

Recommended handling:

  • Check whether appId carried in the HTTP request header is correct.
  • Check whether appId in the request path (URL) is correct.

403

100217

The application hasn't been authorized.

The application has not been authorized.

Recommended handling: In scenarios where applications are not authorized, ensure that request parameter appId is null.

403

1010009

app throttle exceed.

The NA calls the API at a frequency that exceeds the flow control threshold (100 calls per minute by default).

Recommended handling: Contact IoT platform maintenance personnel to adjust the flow control threshold or control the API call frequency.

403

1010005

App_key or access_token is invalid.

The access token is invalid.

Recommended handling: Check whether accessToken carried in the API request is correct.

404

105202

The tag is not existed.

The tag does not exist.

500

100203

The application is not existed.

The application does not exist.

Recommended handling:

  • Check whether appId carried in the HTTP request header is correct.
  • Check whether appId in the request path (URL) is correct.

500

50252

Internal server error.

An internal server error occurs.

Recommended handling: An internal error occurs on the IoT platform. Contact IoT platform maintenance personnel.

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