Ramesh Gurusamy
Ramesh Gurusamy

Reputation: 138

How to create a device in IoT Hub via REST API or SDK

I want to create a device in the IoT Hub when I add a device in my application.

I'm looking for REST Endpoints available for performing operation. Or any SDK available to do this.

Upvotes: 3

Views: 2715

Answers (2)

Roman Kiss
Roman Kiss

Reputation: 8265

Have a look at the following docs:

Service - Create Or Update Device

Control access to IoT Hub

example of the creating DeviceX with auto-generated symmetric keys:

PUT https://myIoTHubName.azure-devices.net/devices/DeviceX?api-version=2018-06-30

headers:

Authorization: sasToken(see the above link)

payload:

{
  "deviceId": "DeviceX"
}

Upvotes: 3

kgalic
kgalic

Reputation: 2664

Here you can find an example of how to using ServiceClient JAVA SDK. For connection string, you can use IoT Hub Owner from shared access policies. If you want a more restrictive approach, make sure you select only registry read and write for this operation.

Upvotes: 0

Related Questions