V2.1 Cancel Command


Cancel cached commands. If a commandId is specified, the command with the commandId will be cancelled. If no commandId is specified, all the device’s cached commands will be cancelled.


This API is available in EnOS 2.1.0 and above.

Operation Permissions


Before invoking this API, ensure that the service account has been authorized the policy that includes the following service(s) and action permission(s). For how to authorize the service account, see Managing Service Accounts.


Required Service

Required Operation Permission

Asset

Control

Request Format

POST https://{apigw-address}/connect-service/v2.1/commands?action=cancel

Request Parameters (URI)

Note

Use one of the following methods to specify the device:

  • Include assetId in the request

  • Include productKey + deviceKey in the request

Name

Location (Path/Query)

Mandatory/Optional

Data Type

Description

orgId

Query

Mandatory

String

The organization ID which the asset belongs to. How to get orgId>>

assetId

Query

Optional (See Note above)

String

The asset ID. How to get assetId>>

productKey

Query

Optional (See Note above)

String

The product key. To be used with deviceKey.

deviceKey

Query

Optional (See Note above)

String

The device key. To be used with productKey.

commandId

Query

Mandatory

String

The command ID.

Response Parameters

Name

Data Type

Description

data

Array of Command Structs

The list of cancelled commands. For details, see Command Struct.

Command Struct

Name

Data Type

Description

commandId

String

The command ID.

orgId

String

The organization ID which the asset belongs to.

productKey

String

The product key.

deviceKey

String

The device key.

assetId

String

The asset ID.

createTime

String

The time when the command was invoked.

createLocaltime

String

The local time when the command was invoked.

commandType

Integer

The command type.

  • 1 = Measurement point setting

  • 2 = Service invocation

commandName

StringI18n

The command name. Refers to the measurement point name for measurement point setting. Refers to the service name for service invocation.

timeout

Integer

The command timeout duration. Its unit is seconds and its range is [1-60]. The default value is 30.

pendingTtl

Long

The command cache duration. Its unit is seconds and its range is [ 0 - 48 * 60 * 60 ], which is 0 by default. If the pendingTtl is 0, it indicates that the commands will be executed immediately.

state

Integer

The command status, which is represented by an integer from 1-7.

  • 1 = Created

  • 2 = Canceled

  • 3 = Expired

  • 4 = Released

  • 5 = Send successfully

  • 6 = Failed

  • 7 - Response timed out

tslIdentifier

String

The corresponding identifier in the ThingModel. Refers to the measurement point identifier for measurement point setting. Refers to the service identifier for service invocation.

inputData

Map (Key is of String type and the Value is of String, Number, Array or Object type)

The input data. For measurement point setting commands, the key is the measurement point identifier and the value is the measurement point value to be set. For service invocation commands, the key is the service input parameter identifier. The value data type will be as per defined in the ThingModel.

outputData

Map (Key is of String type and the Value is of String, Number, Array or Object type)

The output data. No return value is provided for this field for measurement point setting commands. For service invocation commands, this will return the service output results. The value data type will be as per defined in the ThingModel.

Error Codes

Code

Message

Description

11404

Command not found

The commandId cannot be found or does not exist.

11905

Cache message cancel error, not created state

The command is already revoked.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/commands?action=cancel&deviceKey=yourDeviceKey&productKey=yourProductKey&orgId=yourOrgId&commandId=2278935391225618432
method: POST

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "7d863d517eae4f18a2776452eb1305bb",
    "data": [{
        "commandId": "2278935391225618432",
        "orgId": "yourOrgId",
        "productKey": "yourProductKey",
        "deviceKey": "yourDeviceKey",
        "assetId": "yourAssetId",
        "createTime": "1560505243577",
        "createLocalTime": "2019-06-14 17:40:23",
        "commandType": 1,
        "commandName": {
            "defaultValue": "Int_value",
            "i18nValue": {
                "en_US": "Int_value"
            }
        },
        "timeout": 1,
        "pendingTtl": 6000,
        "state": 1,
        "tslIdentifier": "Int_value",
        "inputData": 222,
        "outputData": null
    }]
}

SDK Samples


You can access the SDK samples for Connection Service on GitHub: