Home > Software engineering >  Azure IoT Hub Rest API returns "InvalidProtocolVersion;Bad Request"
Azure IoT Hub Rest API returns "InvalidProtocolVersion;Bad Request"

Time:07-08

I'm new to Azure IoT Hub

What I'm trying to do is remove pending commands for a device in the IoT Hub by using Azure IoT Hub's REST API as shown here here

But I keep getting the same error "InvalidProtocolVersion;Bad Request"

see this postman request

I added a SAS Token in the header and changed the api-version parameter but nothing works.

Can anybody help ?

CodePudding user response:

I added a SAS Token in the header and changed the api-version parameter but nothing works.

According to documentation:

  • DELETE operations may include the following header: If-Match = [*|<etag from get>]

Alternatively, you can use the following documented Azure CLI command to purge cloud-to-device message queue for a target device:

az iot device c2d-message purge --device-id
                                [--hub-name]
                                [--login]
                                [--resource-group]

Updated answer:

According to Eyasu Bogale:

Sas Token did not have all the permission it needed. Generated it using az iot hub generate-sas-token -n roboatiothub --policy iothubowner (not registryRead) and now it works (even without the If-Match header)

References: Azure IoT Hub InvalidProtocolVersion and Control access to IoT Hub

  • Related