Search code examples
azureiot

Azure Iot Rest API Message from cloud to device


Get : https://myiot.azure-devices.net/devices/mydevice/messages/devicebound?api-version=2016-02-03

Authorization: SAS key

i am getting 204 No content response from above api while receiving message using postman request maker from cloud to device.When i send messages from device to cloud it is appearing in my iot hub but giving error 204 while receiving messages from cloud.


Solution

  • First, if you haven't sent Cloud-To-Device messages and you get No content response(error code:204) from calling the GET api(https://myiot.azure-devices.net/devices/mydevice/messages/devicebound?api-version=2016-02-03). It is expected. It means the server has fulfilled the request, but there is no new information to send back.

    Second, you want to receive the Device-To-Cloud message you have sent. It is unreachable. Because this GET api is used to receive Cloud-To-Device messages.

    In short, Device-To-Cloud and Cloud-To-Device are different messaging primitives that Azure IoT hub provides to communicate with a device. And Device-To-Device communication that you want is not supported natively with Azure IoT Hub.

    Finally, how to send Cloud-To-Device message?

    For test purpose, you can send Cloud-To-Device message from Device Explorer. More detailed information you can reference here.