Getting 401 on REST call to IoTHub (on 'devicebound')

Sagar Epari 75 Reputation points
2023-08-16T13:00:50.5833333+00:00

Hi Team,

I want to send C2D from a web page. I am able to make REST call to IoTHub on 'events' but not on 'devicebound'. I am getting unauthorized 401 when I post on 'devicebound'. On 'events', I get 204 as expected and I see my message on built-in endpoint.

Note: Just to be sure I have created SAS token with iothubowner policy. Am I missing anything? I believe the same SAS token should work for both, right? Maybe, there is gap in my understanding.

My REST code,

const response = await fetch(`https://myhub.azure-devices.net/devices/device_xyz/messages/devicebound?api-version=2020-03-13`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': sasToken
                    },
                    body: message
                });
Azure IoT Hub
Azure IoT Hub

An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    8 deleted comments

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.