V2.1 Create Product


Create a product.


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

Product

Create

Prerequisite

You have learnt the Limitations about products.

Request Format

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

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

productDesc

Optional

String

The product description.

biDirectionalAuth

Mandatory

Boolean

  • true: supports two-way authentication

  • false: does not support two-way authentication

modelId

Mandatory

String

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

dataFormat

Mandatory

String

Supports only two values: Custom and Json.

  • Custom represents the user-defined data type.

  • Json represents the JSON data type.

productName

Mandatory

StringI18n

The product name. For more details on the structure and locales supported, see Internationalized name struct.

productType

Mandatory

String

Supports only two values: Device and Gateway.

  • Device represents common product types.

  • Gateway represents gateway types.

dynamicActivateEnabled

Optional

Boolean

  • true: able to activate dynamically

  • false (default): not able to activate dynamically

productTags

Optional

Map

The tags of the product. For details, see How to use tags.

defaultValidDay

Optional

Integer

Only applicable when biDirectionalAuth is true. This parameter is used when a device/gateway under this product applies for a certificate. When the device/gateway applies for a certificate but does not specify the validity period, this parameter will be used as the certificate validity period. The range is 1 to 3650, and the default value is 730.

maxValidDay

Optional

Integer

Only applicable when biDirectionalAuth is true. The maximum certificate validity period of a device/gateway when a device/gateway under this product applies for a certificate. If the validity period is exceeded, an error will be reported and the certificate application will fail. The range is 1 to 3650, and the default value is 1095.

Response Parameters

Name

Data Type

Description

data

String

The key of the created product.

Error Codes

Code

Message

Description

99500

Query model failed

The modelId does not exist.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/products?action=create&orgId=yourOrgId
method: POST
requestBody:
{
    "productDesc":"openapi_sdk_create_test",
    "biDirectionalAuth":false,
    "modelId":"AlterTest0615",
    "dataFormat":"Custom",
    "productName":{
        "defaultValue":"AlterTest0615_Product",
        "i18nValue":{}
    },
    "productType":"Device",
    "dynamicActivateEnabled":false,
    "productTags": {
        "key1": "v1"
    }
}

Return Sample

{
    "code":0,
    "msg":"OK",
    "requestId":"522d0269-445d-4f13-be04-1424e0e2893e",
    "data":"2zp6A70r"
}

SDK Samples


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