Get Asset Trees


Get the details of one or multiple asset trees based on a set of assetIds. If the assetId is not in the tree, no Key will be returned in data.

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

Request Format

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

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

assetIds

Mandatory

String Array

Provide multiple asset IDs if you want to query multiple assets. The array can support a max of 100 IDs. Applicable to both device and non-device (logical) assets. How to get assetId>>

projection

Optional

Projection Struct

Enables you to crop the data result set returned in the interface request if needed. Only the specified fields will be returned in the data result set if this parameter is used. Otherwise all fields are returned. When specifying a field, use the format *.[*].parameter. For example: *.[*].treeId

How does projection crop the result set>>

Note: EnOS Edge does not support this parameter.

Response Parameters

Name

Data Type

Description

data

Map

A list of assets and the asset trees they are in. The Key is assetId and the Value is the assetTree struct array. For more details, see AssetTree Struct.

Error Codes

Code

Message

Description

99400

Invalid arguments

The request parameter is invalid. Check the request parameters.

99500

System error

Internal server error. Contact EnOS support.

Samples

Request Sample

url: https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?action=getAssetTree&orgId=yourOrgId
method: POST
requestBody:
{
  "assetIds": ["BtsYmF2r", "qf1vsBQW"]
}

Return Sample

{
 "code": 0,
 "msg": "OK",
 "requestId": "82248518-6da4-49d2-8d07-cf7a0ff55b60",
 "data": {
 "BtsYmF2r" : [{
   "treeId" : "yourTreeId",
   "tags" : { },
   "asset": {
    "modelId": "yourModelId",
    "assetId": "yourAssetId",
    "timezone": "+08:00",
    "name": {
     "i18nValue": {
      "en_US": "zmTree604111zzz"
     },
     "defaultValue": "zmTree604"
    },
    "description": "",
    "attributes": {},
    "inValid": false,
    "label": "1",
    "modelIdPath": "/NULLMODEL",
    "tags": {}
   }}
 ]
 }
}

SDK Samples


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