百度智能云

All Product Document

          IoT Core

          Device Management

          Create a Device

          Used to create a device.

          Method API Description
          POST /v1/iotcore/{iotCoreId}/device/new Create a single device

          Request parameter

          Parameter name Parameter type Required or not Description
          iotCoreId string Required The id of URLPath and IoT Core can be accessed in IoT Core list.
          name string Required The unique identity of a device in IoT Core is synonymous with deviceName and deviceId
          templateId string Required Id of the device template can be viewed in the console.
          authType string Required Authentication type, optional value: SIGNATURE key, CERT certificate; it defaults to be SIGNATURE
          desc string Required The device description information consists of 0-128 arbitrary characters

          Return normally

          HTTP Code: 201

          When authType is SIGNATURE:

          Name Type Description
          name String The unique identity of a device in IoT Core is synonymous with deviceName and deviceId
          createTs Long Creation time
          authType String Authentication type
          secretKey String DeviceSecret generated

          When authType is CERT:

          Name Type Description
          name String The unique identity of a device in IoT Core is synonymous with deviceName and deviceId
          createTs Long Creation time
          authType String Authentication type
          privateKey String Private key
          clientCert String Certificate content

          Exceptional return

          Error code code Description
          400 BadRequest Parameter error; any request parameter cannot meet the specification
          400 QuotaExhausted Quota used up: number of devices created reaches the upper limit
          403 forbidden Not accessible; you have no access privilege to the current iotCore
          500 INTERNAL_SERVER_ERROR Internal error; the client can try again in this state.

          Request example

          POST /v1/iotcore/aweqgsn/device/new HTTP/1.1 
          Host: iot.baidubce.com 
          Authorization: {authorization} 
          Content-Type: application/json; charset=utf-8 
          { 
            "name" : "devicetest1", 
            "desc" : "This is a test device.", 
            "templateId" : "t3837fa0", 
            "authType" : "SIGNATURE" 
          } 

          Return example

          { 
              "name":"devicetest1", 
              "desc":"This is a test device.", 
              "createTs":1583910343986, 
              "authType":"SIGNATURE", 
              "secretKey":"hybKqPmfEYwWvCRj" 
          } 

          Example for exceptional return

          { 
              "requestId": "49eb817c-636d-4de1-b2c2-67a6004742f8", 
              "code": "DeviceNameOccupied", 
              "message": "Device name has been occupied, iotCoreId=aweqgsn, deviceName=test" 
          } 

          Delete Device

          Used to delete the device.

          Method API Description
          DELETE /v1/iotcore/{iotCoreId}/device/{deviceName} Delete individual device

          Request parameter

          Parameter name Parameter type Required or not Description
          iotCoreId string Required Id of URLPath and IotCore
          deviceName string Required URLPath,The unique identity of a device in IoT Core is synonymous with name and deviceId during the device creation.

          Return normally

          HTTP Code: 200

          Exceptional return

          Error code code Description
          400 BadRequest Parameter error; any request parameter cannot meet the specification
          403 forbidden Not accessible; you have no access privilege to the current iotCore
          404 DeviceNotFound No device found; no device designated to delete is found in IoT Core.
          500 INTERNAL_SERVER_ERROR Internal error; the client can try again in this state.

          Request example

          DELETE /v1/iotcore/aweqgsn/device/devicetest1 HTTP/1.1 
          Host: iot.baidubce.com 
          Authorization: {authorization} 

          Return example

          HTTP Code: 200 

          Example for exceptional return

          { 
          "requestId":"b345ad9a-7e78-4542-bc35-6c82f0c2e2d3", 
          "code":"DeviceNotFound", 
          "message":"Device not found, deviceName=mydevicename" 
          } 
          Previous
          Overview
          Next
          Best Practices