It needs to be URL-encoded, I guess. At least, I couldn't get it to work with JSON. So, modify your request body to ensure your queries are URL-encoded, and update your header content type to "application/x-www-form-urlencoded" as well. Then, it should work.
If it's not on a Shelly device, you could use OAuth to gain access to your Shelly cloud devices.
Code
var server= 'https://shelly-xx-eu.shelly.cloud'; //xx needs to be your own cloud id.
var cloud_API_key= 'your_api_key';
var device_Mac= 'Shelly_MAC';
Shelly.call(
"http.request",{
method: "POST",
url: server+'/device/relay/control',
headers: {"Content-Type":"application/x-www-form-urlencoded"},
body: 'channel=0&turn=on&id='+device_Mac+'&auth_key='+cloud_API_key
},function(r){print(r);}
);
Alles anzeigen