Request Example for Azure IoT Hub REST API query

Justin Pham 46 Reputation points

I want to query the Azure IoT hub through a the query endpoint using an http request. Currently I am receiving a Internal Server Error with the following request through Postman:

with a request body containing {query: "SELECT * FROM devices"}

Directly querying the hub with the query works so I believe that it is valid and other requests are authenticating properly so I am believe that it is a problem with how I am formatting my request.

Can someone point out which part of my requests is causing the issue or provide a working example with the same endpoint?


Note: The documentation for the request can be found here

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,147 questions
0 comments No comments
{count} votes

Accepted answer
  1. Matthijs van der Veer 4,376 Reputation points MVP

    Make sure to set the content type of the body to JSON. If it's not set to the correct content type, you will get an internal server error.

    While it won't result in an error, you should also write "query" with double-quotes. The above will work, but Postman will tell you it's not technically valid JSON.

    0 comments No comments

0 additional answers

Sort by: Most helpful