Not many know and use it: Azure IoT Hub supports a REST API which can be used for sending and receiving messages. The example describes how it can be tested with postman.

How does it work?

Setup Azure

  1. Login to your Azure Subscripiton
  2. Create an IoT Hub
  3. Create an device and enable it

Setup Device Explorer Twin

  1. Download and install Azure Device Explorer (use MSI file in the download section)
  2. Open Device Explorer …
  3. and connect to you IoT hub with the Iot Hub connection string in the tab configuration
  4. Go to tab Management and select SAS Token
  5. Generate a SAS Token for the device you have created earlier
  6. Copy the SAS Token starting from
 SharedAccessSignature=SharedAccessSignature  sr=<youriothubname>.azure-devices.net%2Fdevices%2F<deviceid>&sig=....

Setup Postman

  1. Open Postman
  2. create a new Post
  3. New Type Post
  4. set URL to https://<iothubname>/devices/<deviceid>/messages/events?api-version=2018-06-30 if you want to send events from Device to cloud
  5. Add the following request headers
    1. Content-Type to application/xml
    2. Authorization to <paste the SAS>
  6. As a body add the message you want to send

Monitor activities

Option 1 Device Explorer:

  1. click tab Data
  2. select the deviceid and choose monitor
  3. The messages should be displayed there after sending

Option 2 Visual Studio Code:

  1. Connect to the IoT Hub and monitor the activities either on device or hub level

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.