创建请求属性 - CreateRequestProperty
功能介绍
创建请求属性。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项。
URI
POST /v2/{project_id}/link/instances/{instance_id}/services/{service_id}/commands/{command_id}/requests
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
project_id | 是 | String | 项目ID,兼容20.0场景默认为default。项目ID,获取方式请参见API参考的“附录 > 获取项目ID”章节。 |
instance_id | 是 | String | 实例ID。兼容20.0场景默认为default。 |
service_id | 是 | String | 服务ID,该字段为数据库中的自增唯一标识符;通过调用查询服务接口:GET /v2/{project_id}/link/instances/{instance_id}/services获取响应体中对应服务的service_id字段值。 |
command_id | 是 | Integer | 命令ID,该字段为数据库中的自增唯一标识符;通过调用查询命令接口:GET /v2/{project_id}/link/instances/{instance_id}/services/{service_id}/commands获取响应体中对应命令的command_id字段值。 |
请求参数
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
X-Auth-Token | 是 | String | 用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
property_name | 是 | String | 属性名称,首位必须为字母,支持大小写字母、数字、中划线及下划线,长度2-50。 |
description | 否 | String | 属性描述,长度0-200。 |
data_type | 是 | String | 属性数据类型,boolean枚举值大小写敏感,长度限制10;number格式为数字,范围±1.0 x 10^-28 to ±7.9228 x 10^28,长度限制50;string为字符串,长度限制200;integer为整数,长度限制50;datetime为时间,格式为yyyyMMddTHHmmss,长度限制100;json为自定义json格式,长度限制100;array为数组类型,长度限制2000。 |
required | 是 | Integer | 是否必填,0-非必填,1-必填。 |
min | 否 | String | 最小值,当data_type为integer或number时必填。 |
max | 否 | String | 最大值,当data_type为integer或number时必填。 |
step | 否 | String | 步长,当data_type为integer或number时必填。 |
max_length | 否 | Integer | 字符串最大长度,当data_type为string、datetime、 json时必填,自动向下取整。 |
unit | 否 | String | 属性单位。 |
enum_list | 否 | String | string的枚举值数组,使用逗号分隔,单个长度取决于max_length参数。 |
enum_dict | 否 | Object | 当数据类型为boolean枚举值时填写json格式数据,形如"enum_dict":{"0":"xxx","1":"xxx"}。 |
method | 否 | String | 访问模式(兼容20.0,R属性可读,W属性可写,E属性可执行)。 |
响应参数
状态码:200
参数 | 参数类型 | 描述 |
|---|---|---|
property_id | Integer | 属性ID。 |
property_name | String | 属性名称,首位必须为字母,支持大小写字母、数字、中划线及下划线,长度2-50。 |
description | String | 属性描述,长度0-200。 |
data_type | String | 属性数据类型,boolean枚举值大小写敏感;number格式为数字,范围±1.0 x 10^-28 to ±7.9228 x 10^28;string为字符串;integer为整数;datetime为时间,格式为yyyyMMddTHHmmss;json为自定义json格式; array为数组类型。 |
required | Integer | 是否必填,0-非必填,1-必填。 |
min | String | 最小值,当data_type为integer或number时有效。 |
max | String | 最大值,当data_type为integer或number时有效。 |
step | String | 步长,当data_type为integer或number时有效。 |
max_length | Integer | 字符串最大长度,当data_type为string、datetime、json时有效。 |
unit | String | 属性单位。 |
enum_list | String | string的枚举值数组,使用逗号分隔,单个长度取决于max_length参数。 |
enum_dict | Object | 当数据类型为boolean枚举值时填写json格式数据,形如"enum_dict":{"0":"xxx","1":"xxx"}。 |
状态码:400
参数 | 参数类型 | 描述 |
|---|---|---|
error_code | String | 系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。 |
error_msg | String | 错误描述。 |
request_id | String | 消息ID。 |
状态码:404
参数 | 参数类型 | 描述 |
|---|---|---|
error_code | String | 系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。 |
error_msg | String | 错误描述。 |
request_id | String | 消息ID。 |
状态码:500
参数 | 参数类型 | 描述 |
|---|---|---|
error_code | String | 系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。 |
error_msg | String | 错误描述。 |
request_id | String | 消息ID。 |
请求示例
为指定命令创建一个请求属性,数据类型为Integer,属性非必填,并设置最小和最大值。
{
"property_name" : "power_usage",
"description" : "power_usage",
"data_type" : "integer",
"required" : 0,
"min" : "0",
"max" : "100",
"step" : "1",
"unit" : "W"
} 响应示例
状态码:200
Created
{
"property_id" : 3320,
"property_name" : "p2",
"description" : null,
"data_type" : "datetime",
"required" : 0,
"min" : 0,
"max" : 65536,
"step" : 1,
"max_length" : "10",
"unit" : "yuan",
"enum_list" : null,
"method" : "RWE"
} 状态码:400
Bad Request
{
"error_code" : "SCB.00000000",
"error_msg" : "Parameter is not valid for operation [romalink.link-services-requests.saveCommandSend]. Parameter is [service_id]. Processor is [path].",
"request_id" : "cb39e78a-afd3-4e04-901d-70468b1c23dc-1619602712496-cnnorth7a-P-romalink-service01"
} 状态码:404
Not Found
{
"error_code" : "ROMA.00110006",
"error_msg" : "The resource does not exist. Check whether the resource ID 1 is correct.",
"request_id" : "13984193-ca65-4954-9b7f-4b7d680399d6-1619678681445-cnnorth7a-P-romalink-service01"
} 状态码:500
Internal Server Error
{
"error_code" : "ROMA.00110002",
"error_msg" : "The instance does not exist. project_id: 397cd10b30544c588b2f4a56d83856c4, instance_id: f3bb386a-23ec-47aa-9943-4c60ac658611",
"request_id" : "c8c06d0a-be92-4fdf-9d10-bc20131ab158-1619593104919-cnnorth7a-P-romalink-service01"
} 状态码
状态码 | 描述 |
|---|---|
200 | Created |
400 | Bad Request |
404 | Not Found |
500 | Internal Server Error |
错误码
请参见错误码。

