Create Product


Create a product.

Operation Permissions

Required Authorization

Required Operation Permission

Device Management

Full Access

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

This parameter is used when a device under this product applies for a certificate. When the device 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

The maximum certificate validity period of a device when a device 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

Description

11699

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"
}

Java SDK Sample

package com.envisioniot.enos.api.sample.connect_service.product;

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.api.common.constant.common.StringI18n;
import com.envisioniot.enos.connect_service.v2_1.product.CreateProductRequest;
import com.envisioniot.enos.connect_service.v2_1.product.CreateProductResponse;

public class CreateProduct {

    public static void main(String[] args) {
        String appKey = "yourAppKey";
        String appSecret = "yourAppSecret";
        String serverUrl = "yourSeverUrl";

        String orgId = "yourOrgId";
        CreateProductRequest request = new CreateProductRequest();
        request.setOrgId(orgId);
        StringI18n productName = new StringI18n("yourProductName");
        request.setProductName(productName);
        request.setProductDesc("yourProductDesc");
        request.setBiDirectionalAuth(false);
        request.setDataFormat("Custom");
        request.setProductType("Device");
        request.setModelId("yourModelId");
        CreateProductResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                .url(serverUrl)
                .getResponse(request, CreateProductResponse.class);
    }
}