V2.1 Update Device


Update a device. The assetId (or productKey + deviceKey) parameter is to be specified in the request url, and other parameters are to be specified in the request body.


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
Device Management Service Full Access

Prerequisite

  • The required device exists.
  • You have learnt the Limitations about devices.

Request Format

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

Request Parameters (URI)

Note

Use one of the following methods to specify the device to be updated:

  • 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.
isPatchUpdate Query Optional Boolean
  • true (default): Only the fields specified in the parameters are updated. The values of those fields not specified will be retained.
  • false: The fields specified in the parameters are updated. Those fields not specified will have their existing values (if any) deleted or overwritten by their default values(if any). Note that timezone and deviceName need to be specified when isPatchUpdate is false.

Request Parameters (Body)

Name Mandatory/Optional Data Type Description
timezone Optional String Timezone of the device’s location.
deviceName Optional StringI18n The device name. For more details on the structure and locales supported, see Internationalized name struct.
deviceAttributes Optional Map The device attributes.
deviceTags Optional Map The device tags. (The Key and Value are of String type.) For more details, see How to use tag.
deviceDesc Optional String The device description.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/devices?action=update&orgId=yourOrgId&assetId=yourAssetId
method: POST
requestBody:
{
    "deviceTags": {
        "test": "test_value"
    },
    "deviceAttributes": {
        "int11": 617
    },
    "deviceName": {
        "defaultValue": "testforname",
        "i18nValue": {}
    },
    "deviceDesc": "test for updatedevice"
}

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "0d61752e-0633-4846-abb1-b6fb39801a5f",
    "data": null
}

SDK Samples


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