Using an API command in Node Red to toggle a switch

This is my first time at using the API to send a command.

I have successfully received the status of the switch (using bearer authorization)

the status reply is:

But my attempt at sending the command below fails and returns 406

PUT{deviceId}/commands.components.main.switch.switch.value. [off]

Postman status reply:
“components”: {
“switch”: {
“switch”: {
“value”: “off”

Please could someone give me a pointer
Thanks in advance


Here is the answer just in case anyone has the same question:

make a function node to feed a blank ‘http request’ node - but set to method “-setby msg.method-”

var xxx = “off”;
msg.payload = {
“commands”: [{
“component”: “main”,
“capability”: “switch”,
“command”: xxx,
“arguments”: //<----open square bracket closed square bracket!!
msg.headers = {}
msg.method = “POST”
msg.url = “{{deviceid}}/commands”;
msg.headers[‘content-type’] = “application/json”
msg.headers[‘Authorization’] = “Bearer xxxxxxxxx-PAT-token-xxxxxxxxxxxx”
return msg;

1 Like