V2.1 Search Device Upgrade


Search for the firmware and upgrade status of the device based on the search criteria.


This API is available in EnOS 2.2.0 and above.

If you need to invoke this API after performing bulk updates to relevant devices using other APIs, it is recommended to wait for about 2 seconds to avoid obtaining unupdated data.

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

Firmware

Read

Request Format

POST https://{apigw-address}/connect-service/v2.1/ota-firmwares?action=searchDeviceUpgrade

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

expression

Optional

String

The query expression, which supports sql-like query. The fields that are supported for query include: productKey, firmwareVersion, and isUpgrading.

  • productKey and firmwareVersion: supports arithmetic operator “=” and “in”.

  • isUpgrading: supports arithmetic operator “=”.

pagination

Optional

Pagination Request Struct

Lists the paging requirements in a request. When not specified, 10 records are displayed per page by default. The maximum records per page is 200 but for optimal performance, it is recommended to have not more than 50 records per page. sorters is not supported to sort the response. For more details, see Pagination Request Struct>>

Response Parameters

Name

Data Type

Description

data

Array of DeviceFirmware Structs

The list of firmware information. For details, see DeviceFirmware Struct>>

DeviceFirmware Struct

Name

Data Type

Description

orgId

String

The organization ID which the asset belongs to.

assetId

String

The asset ID.

productKey

String

The product key.

deviceKey

String

The device key.

firmwareVersion

String

The firmware version.

isUpgrading

Boolean

  • true: Currently being upgraded.

  • false: The upgrading has ended. The upgrade result may be successful or may have failed.

Error Codes

For the description of error codes, see Common Error Codes.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/ota-firmwares?action=searchDeviceUpgrade&orgId=yourOrgId
method: POST
requestBody:
{
    "expression": "productKey='yourProductKey'",
    "pagination": {
        "pageNo": 1,
        "pageSize": 5
    }
}

Return Sample

{
    "code":0,
    "msg":"OK",
    "requestId":"7bd0040b-63c6-4173-b764-d2e8d6642dd3",
    "data":[
        {
            "orgId":"o15475466766371",
            "assetId":"rFFJ6j53",
            "productKey":"8UhOTwV5",
            "deviceKey":"WnszKfi8NU",
            "firmwareVersion":"7777",
            "isUpgrading":false
        },
        {
            "orgId":"o15475466766371",
            "assetId":"qOE2FZb5",
            "productKey":"BXwU4kMk",
            "deviceKey":"ota-device2",
            "firmwareVersion":"2.0",
            "isUpgrading":true
        },
        {
            "orgId":"o15475466766371",
            "assetId":"kYK5nVJv",
            "productKey":"8UhOTwV5",
            "deviceKey":"bCUsvJvEBT",
            "firmwareVersion":"2020.01",
            "isUpgrading":false
        },
        {
            "orgId":"o15475466766371",
            "assetId":"VeHlM7wW",
            "productKey":"8UhOTwV5",
            "deviceKey":"1HshYDJ3wf",
            "firmwareVersion":"2020.01",
            "isUpgrading":false
        },
        {
            "orgId":"o15475466766371",
            "assetId":"TGEIuAWG",
            "productKey":"8UhOTwV5",
            "deviceKey":"bfb1EcjaKG",
            "firmwareVersion":"7.7",
            "isUpgrading":false
        }
    ],
    "pagination":{
        "sortedBy":null,
        "pageNo":1,
        "pageSize":5,
        "totalSize":9
    }
}

SDK Samples


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