Batch Associate Asset


Batch link existing assets to an asset tree. The assets to be linked can be a device asset or a logical asset. For device assets, you can use the product key + device key or asset ID to describe. For logical assets, you should use the asset ID to describe.

Operation Permissions


Ensure that you have the permission to invoke this API. For more information, see Getting API Calling Permissions.

Request Format


POST https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?action=associateAssetBatch

Request Parameters (URI)


Name

Location (Path/Query)

Required/Optional

Data Type

Description

orgId

Query

Required

String

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

treeId

Query

Required

String

The asset tree ID. How to get treeID>>

parentAssetId

Query

Required

String

The asset ID of the parent node of the asset to be linked.

Request Parameters (Body)


Name

Required/Optional

Data Type

Description

assetIdentifiers

Required

Array of AssetIdentifiersVo Structs

The asset information. For more information, see AssetIdentifiersVo Struct.

Response Parameters


Name

Data Type

Description

data

Array of EnosBatchEachData Struct

The list of success or failure messages. For more information, see EnosBatchEachData struct.

successSize

Integer

The number of successfully linked assets.

totalSize

Integer

The total number of assets to be linked.

Error Codes


Code

Message

Description

17752

Parent assetId is not existed in the tree

The parent asset does not exist in this Tree

17758

AssetId is existed in the tree

Asset ID already exists in the tree.

17762

The tree is locked

The asset tree cannot be modified/deleted for the time being as someone is currently accessing the asset tree. Please try again later.

17770

Exceeding the layer limit(7)

The tree exceeds the maximum number of layers (7 layers).

99400

Invalid arguments

The request parameter is invalid. Check the request parameters.

99404

TreeId is not exist

The tree ID does not exist.

99500

System error

Internal server error. Contact the system administrator.

Samples

Request Sample


url: https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?action=associateAssetBatch&orgId=yourOrgId&treeId=yourTreeId&parentAssetId=yourParentAssetId
method: POST
requestBody:
{
  "assetIdentifiers": [
    {
      "assetId": "assetId1"
    },
    {
      "deviceKey": "yourDeviceKey",
      "productKey": "yourProductKey"
    }
  ]
}

Return Sample


{
  "code":99206,
  "msg":"Partial Content Success",
  "requestId":"deb2cf9d-b512-456f-b046-30e365c54e9c",
  "data":[
      {
          "code":758,
          "msg":"asset is existed in the tree.",
          "data":"assetId1"
      },
      {
          "code":0,
          "msg":"OK",
          "data":"assetId2"
      }
  ],
  "successSize":1,
  "totalSize":2
}

SDK Samples


You can access the SDK samples for Asset Tree Service on GitHub: