V2.5 Create Command Jobs


Create command jobs.

Request Format

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

Request Parameters (URI)

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

Request Parameters (Body)

Name

Mandatory/Optional

Data Type

Description

name

Mandatory

StringI18n

The job name. For more details on the structure and locales supported, see Internationalized name struct.

targetScope

Mandatory

Struct

See TargetScope Struct.

schedulePolicy

Mandatory

Struct

See SchedulePolicy Struct.

timeoutPolicy

Optional

Struct

See TimeoutPolicy Struct.

retryPolicy

Optional

Struct

See RetryPolicy Struct.

desc

Mandatory

String

The job description with no more than 100 characters.

commandInfo

Mandatory

Struct

See commandInfo Struct.

Response Parameters

Name

Data Type

Description

code

Number

Return code of a request. + 0 indicates success. + non-zero values indicates failure.

msg

String

The explanation to the return code. Its value is OK if the request is successful.

requestId

String

A unique ID to identify a request.

data

String

Null.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.5/commands?action=createJob&orgId=yourOrgId
method: POST
requestBody:
{
    "timeoutPolicy": {
        "inProgressTimeoutInSeconds": 30,
        "ttlTimeoutInSeconds": 20
    },
    "retryPolicy": {
        "enableRetry": true,
        "retryCount": 3,
        "retryIntervalInSeconds": 300
    },
    "name": {
        "defaultValue": "commandJobName",
        "i18nValue": {
            "en_US": "name",
            "zh_CN": "中文名"
        }
    },
    "schedulePolicy": {
        "disposableSchedulePolicy": {
            "triggerTs": 1718952446317
        },
        "scheduleType": "DISPOSABLE"
    },
    "commandInfo": {
        "commandType": "SERVICE_INVOKE",
        "serviceInvokeInfo": {
            "inputData": {
                "input": 22
            },
            "serviceId": "serviceId"
        }
    },
    "targetScope": {
        "targetDevices": [{
            "deviceKey": "deviceKey",
            "productKey": "productKey"
        }],
        "targetType": "DEVICE_LIST"
    },
    "desc": "commandJobDescription"
}

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "95c4bac0-476e-4d07-bd09-1ae096ea24a4",
    "data": "jobId"
}