Help Center/ IoT/ API Reference/ Northbound API Reference/ Batch Processing/ Querying Information About a Specified Batch Task
Updated on 2022-02-24 GMT+08:00

Querying Information About a Specified Batch Task

Typical Scenario

After creating a batch task for devices, an NA can call this API to query information about the batch task, including the task status and the subtask (task performed for a device) completion status.

API Function

This API is used by an NA to query the information about a single batch task by task ID.

API Prototype

Method

GET

URL

https://server:port/iocm/app/batchtask/v1.1.0/tasks/{taskId}?appId={appId}&select={select}

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.

taskId

Mandatory

String

path

Identifies a batch task. The value of this parameter is obtained after the batch task is created.

appId

Optional

String

query

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.

select

Optional

String

query

Indicates an optional return value. The value can be tags.

Response Parameters

Status Code: 200 OK

Parameter

Type

Description

appId

String

Indicates the appId to which the batch task belongs.

taskId

String

Identifies a batch task.

taskName

String

Indicates the name of the batch task.

operator

String

Indicates the operator who delivers the batch task.

taskFrom

String

Indicates the source of the batch task.

  • Portal: The task is created on the SP portal.
  • Northbound: The task is created by calling a northbound API.

taskType

String

Indicates the type of the batch task. The values include DeviceCmd.

status

String

Indicates the status of the batch task. The value options are Pending, Running, Complete, and Timeout.

startTime

String

Indicates the time when the batch task is created.

timeout

Integer

Indicates the time when the batch task times out, in seconds.

progress

Integer

Indicates the progress of the batch task. The value is a permillage ranging from 0 to 1000 and is rounded down.

totalCnt

Integer

Indicates the total number of tasks.

successCnt

Integer

Indicates the number of tasks that are successfully executed.

failCnt

Integer

Indicates the number of tasks that fail to be executed.

timeoutCnt

Integer

Indicates the number of tasks with execution timeout.

expiredCnt

Integer

Indicates the number of expired tasks that are not executed.

completeCnt

Integer

Indicates the number of completed tasks, including successful, failed, and timed out tasks.

successRate

Integer

Indicates the task success rate. The value is a permillage ranging from 0 to 1000 and is rounded down.

param

ObjectNode

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

tags

List<TagDTO2>

Indicates the tag list of the batch task.

ObjectNode structure

Parameter

Type

Description

type

String

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

deviceList

List<String>

Indicates the device ID list. The value is that returned when type is set to DeviceList.

deviceType

String

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

manufacturerId

String

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

model

String

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

deviceLocation

String

Indicates the location of the device. The value is that returned when type is set to DeviceArea.

groupList

List<String>

Indicates the group name list. The value is that returned when type is set to GroupList.

command

CommandDTO

Indicates the command information. .

callbackUrl

String

Indicates the push address of the command execution result..

maxRetransmit

Integer(0-3)

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

groupTag

String

Indicates the group tag.

CommandDTO structure

Parameter

Type

Description

serviceId

String(1-64)

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

String(1-128)

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

ObjectNode

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

Type

Description

tagName

String(1-128)

Indicates the tag name.

tagValue

String(1-1024)

Indicates the tag value.

Request Example

Method: GET
Request:
https://server:port/iocm/app/batchtask/v1.1.0/tasks/******?appId=******
Header:
app_key: ******
Authorization: Bearer ******
Content-Type: application/json;

Response Example

Response:
Status Code: 200 OK
Content-Type: application/json
Body:
{
  "taskId": "********",
  "taskName": "********",
  "appId": "********",
  "operator": "********",
  "taskFrom": "********",
  "taskType": "********",
  "status": "********",
  "startTime": "********",
  "timeout": 1000,
  "progress": 100,
  "totalCnt": 100,
  "successCnt": 70,
  "failCnt": 10,
  "timeoutCnt": 10,
  "expiredCnt": 10,
  "completeCnt": 100,
  "successRate": 70,
  "param": {
    "fileId": "******"
  }
}

Error Codes

HTTP Status Code

Error Code

Error Description

Remarks

400

100019

Illegal request.

Invalid request.

Recommended handling: Check whether the mandatory parameters in the request are set.

400

100022

The input is invalid

An input parameter is invalid.

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

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

105005

The batchTask is not existed.

The batch task does not exist.

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

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.