Associate Asset¶
Associate an existing asset to an asset tree. The asset to be associated 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=associateAsset
Request Parameters (URI)¶
Note
Use one of the following methods to associate an asset:
Include the
assetId
in the requestInclude both
productKey
anddeviceKey
in the request
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 associated. |
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 |
Query |
Optional (See Note above) |
String |
The device key. To be used with |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
String |
The ID of the asset that has been successfully associated. |
Error Codes¶
Code |
Message |
Description |
---|---|---|
17404 |
TreeId is not exist |
The tree ID does not exist. |
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. |
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=associateAsset&orgId=yourOrgId&treeId=yourTreeId&parentAssetId=yourAssetId&productKey=yourProductKey&deviceKey=yourDeviceKey
method: POST
Return Sample¶
{
"code": 0,
"msg": "ok",
"requestId": "01b5477a-374e-49a0-8b68-7dbfe8f0b74f",
"data": "yourAssetId"
}
SDK Samples¶
You can access the SDK samples for Asset Tree Service on GitHub: