Create and Associate Asset


Create an asset and associate it to an asset tree.

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=createAsset

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 associated.

Request Parameters (Body)


Name

Required / Optional

Data Type

Description

asset

Required

Asset Struct

The asset details to be provided when creating an asset. For more information, see Asset Struct

Asset Struct


Name

Required/Optional

Data Type

Description

modelId

Required

String

The model ID which the asset belongs to. How to get modelID>>

name

Required

StringI18n

Specify the asset’s name in its respective locale’s language. For more information, see Internationalized name struct.

timezone

Required

String

The timezone where the asset is located. Use the “+08:00” format for time zones that do not support Daylight Saving Time (DST). Use the “Asia/Shanghai” format for time zones that support DST. For more information, see Timezone representation.

description

Optional

String

The asset description.

attributes

Optional

Map

Attributes of the model which the asset belongs to. For more information, see attributes representation.

tags

Optional

Map

User-defined tags. For more information, see How to use tag.

Response Parameters


Name

Data Type

Description

data

String

The ID of the created asset.

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

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=createAsset&treeId=yourTreeId&parentAssetId=yourParentAssetId&orgId=yourOrgId
method: POST
requestBody:
{
    "asset": {
        "modelId": "STRING-INVERTER-MODEL",
        "name": {
            "defaultValue": "Inverter #1",
            "i18nValue": {
                "en_US": "Inverter #1"
            }
        },
        "timezone": "+08:00",
        "description": "This is a sample asset.",
        "attributes": {
            "foo": 100,
            "bar": "example"
        },
        "tags": {
            "foo": "bar",
            "hello": "world"
        }
    }
}

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: