创建设备
接口说明
应用服务器可调用此接口可在平台注册一个设备,并获取设备ID和密码。
URI
| 请求方法 | POST |
|---|---|
| URI | /api/v3.0/devices |
| 传输协议 | HTTPS |
请求参数
| 名称 | 必选/可选 | 类型 | 位置 | 说明 |
|---|---|---|---|---|
| app_key | 必选 | String | Header | 已鉴权应用的appId。 |
| Authorization | 必选 | String | Header | 请求的认证信息,值为“Bearer ******”,其中******为Auth鉴权接口返回的accessToken。 |
| ownerAppId | 可选 | String | Query | 资源所属应用的appId,访问其他应用所持有的资源时需要填写。 |
| productId | 必选 | String(256) | Body | 产品ID。 |
| name | 可选 | String(256) | Body | 设备名称 |
| nodeId | 可选 | String(256) | Body | 设备在平台内的身份唯一标示,建议取值“厂商Id+设备型号”。 |
| preSecret | 可选 | String(256) | Body | 设备预制密钥,nodeId+preSecret组合可用于设备登录、获取平台分配的设备ID和设备密码。 |
| timeout | 可选 | Integer | Body | 预制密钥有效时间。 |
| isSecure | 可选 | Boolean | Body | 标识设备是否安全接入 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| deviceId | String(256) | 设备ID,平台给设备自动生成的平台内唯一标示ID。 |
| deviceSecret | String(256) | 设备密码,平台给设备自动生成的密码,设备ID+设备密码可用于设备登录。 |
请求示例
POST https://{host}:{port}/api/v3.0/devices?ownerAppId={ownerAppId}
Content-Type: application/json
app_key: ********
Authorization: ********
{
"productId" : "0490d5fb-061b-4b47-8199-5927e0c0453a",
"name" : "device1",
"nodeId" : "******",
"preSecret" : "******",
"timeout" : 0,
"isSecure" : true
} 响应示例
Status Code: 200 OK
Content-Type: application/json
{
"deviceId" : "string",
"deviceSecret" : "string"
} 错误码
| HTTP状态码 | HTTP状态码说明 | 错误码 | 错误码描述 |
|---|---|---|---|
| 200 | OK | 100416 | The device has already been binded. |
| 105401 | The group is not existed. | ||
| 105403 | The number of resource in the group has reach the max. | ||
| 105410 | The group not belong to this app. | ||
| 400 | Bad Request | 00014013 | Invalid input. The isSecure must be true. 处理建议:isSecure只能填写true |
| 100003 | Invalid verify code. | ||
| 100007 | Bad request message. 处理建议:参数不合法,检查参数是否正确。 | ||
| 100426 | The nodeId is duplicated. 处理建议:nodeId冲突,检查nodeId是否唯一。 | ||
| 100452 | The device externalId has exist. | ||
| 100453 | the type of externalId does not match. | ||
| 700001 | Product not exist 处理建议:产品不存在,检查productId是否正确。 | ||
| 700010 | Product has not been installed successful 处理建议:产品注册失败,请选择注册成功的产品。 | ||
| 401 | Unauthorized | 100002 | Invalid access token. 处理建议:token失效或错误的token,检查并填写正确的token或者重新获取token。 |
| 100025 | AppId for auth not exist. 处理建议:appId错误或不存在,检查并填写正确的appId。 | ||
| 403 | Forbidden | 100203 | The application does not exist. 处理建议:授权应用Id不存在,检查并填写正确的ownerAppId。 |
| 100217 | The application hasn't been authorized. 处理建议:应用没有被授权,检查该应用是否有权限。 | ||
| 404 | Not Found | 105202 | The tag is not existed. 处理建议:请先创建对应的标签 |
| 500 | Internal Server Error | 100001 | Internal Server Error 处理建议:联系物联网平台维护人员。 |
| 100441 | The amount of nonSecure device has reached the limit. 处理建议:联系物联网平台维护人员。 |
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.