IoTIoT

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain Service
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Updated at: Feb 24, 2022 GMT+08:00

Creating a Batch Task

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 Description

1
BatchTaskCreateOutDTO createBatchTask(BatchTaskCreateInDTO2 btcInDTO, String accessToken) throws NorthApiException

Class

BatchProcess

Parameter Description

Parameter

Mandatory or Optional

Type

Location

Description

accessToken

Mandatory

String

header

If the Periodically Refreshing a Token API is called, set this parameter to null. Otherwise, set this parameter to the accessToken obtained by the Authentication API.

btcInDTO

Mandatory

BatchTaskCreateInDTO2

body

For details, see BatchTaskCreateInDTO2 structure.

BatchTaskCreateInDTO2 structure

Parameter

Mandatory or Optional

Type

Location

Description

appId

Mandatory

String(64)

body

Uniquely identifies an NA. This parameter is used to identify an NA that can call open APIs provided by the IoT platform. The value of this parameter is obtained when the NA is created on the SP portal of the IoT platform.

timeout

Mandatory

Integer

body

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

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 value can be DeviceCmd.

param

Mandatory

ObjectNode

body

Indicates task parameters. The value of this parameter varies depending on the taskType. For details, see ObjectNode structure.

tags

Optional

List<TagDTO2>

body

Indicates the tag list. For details, see TagDTO2 structure.

ObjectNode:

Parameter

Mandatory or Optional

Type

Location

Description

type

mandatory

String

body

Indicates the batch command type. This parameter is mandatory when taskType is set to DeviceCmd. 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. Set this parameter to the value defined in the profile file.

manufacturerId

Conditionally optional

String

body

Identifies the manufacturer. This parameter is mandatory when type is set to DeviceType. Set this parameter to the value defined in the profile file.

model

Conditionally optional

String

body

Indicates the device model. This parameter is mandatory when type is set to DeviceType. Set this parameter to the value 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

Conditionally optional

String

body

Indicates the push address of the command execution result.

maxRetransmit

Conditionally optional

Integer(0~3)

body

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

groupTag

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

Return Value

BatchTaskCreateOutDTO

Parameter

Type

Description

taskID

String

Identifies a batch task.

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.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel