Search code examples
postibm-cloudnode-redwatson-iot

How to send a device management request using NodeRed or any REST client


I am trying to sent a DM firmware update command from a NodeRed Flow.

Function node:

msg.payload = {"MgmtInitiationRequest": {
"action":"firmware/update",
"devices": [{
"typeId": "myType",
"deviceId": "myDevice"
}]

}}
msg.headers={"Content-Type":"application/json"}
return msg;

I send it to a http request node with a POST to

https://orgid.internetofthings.ibmcloud.com/api/v0002/mgmt/requests

Basic Authentication with api keys. I based it of Initiate a device management request

I get back a 403 which the docs have as:

One or more of the devices does not support the requested action

Anyone see what I'm missing? It works fine from the IoT Platform UI to the same devicetype/deviceid.

EDIT: Same 403 if I use a Rest client like Postman.


Solution

  • The swagger API documentation is a little bit misleading in that the 'body' parameter is given a name. But, like the other POST APIs, that name isn't actually included anywhere as part of the payload.

    The payload should just look like this:

    {
        "action": "firmware/update",
        "devices": [
            {
                "typeId": "string",
                "deviceId": "string"
            }
        ]
    }
    

    This page in the documentation provides more detail: https://console.ng.bluemix.net/docs/services/IoT/devices/device_mgmt/requests.html#firmware-actions-update