I am trying to write a script so the Shelly is sending a REST request to a external server.
The info I need is:
how to add a header to the request using Shelly.call() ?
I am getting response.code 401, it seems that the header with the auth info is not send correctly.
My script so far :
Code
Shelly.call(
"HTTP.GET",
{"url": "https://abcd.com",
"headers": {"API-Key": "abcdefg"},
"Content-Type":"application/json"},
function (response) {
print("processing response");
if (response && response.code && response.code === 200) {
print("response.code : ", response.code);
print(JSON.stringify(response.body));
Shelly.emitEvent("HTTP-result", response.body);
}
else {
print("Error: HTTP request failed.");
print("response.code : ", response.code);
}
}
);
Alles anzeigen
Edit by 66er:
Code placed in Code-Tag