Hello everybody.
I have a HomeAssistant configured with some equipment (Relays), I created the scripts, I can test them and it is working ok.
In Postman I can also access the Script via HTTP to execute the Relays, everything works fine.
But I created an application in Node.Js on the same computer as HomeAssistent, so that Node fires the triggers (executes the scripts and activates the relays), because I want to automate the operation of the scripts based on external data. So far so good, in isolation I can test each action and they are all working.
I am using Bearer Token to authenticate.
But when I make requests through Node.Js, I always get the response “401: Unauthorized”.
I’m using the URL
http://homeassistant.local:8123/api/services/script/turn_on
My POST method header is:
{
Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
Content-Type': "application/json"
}
And the body is:
{ "entity_id" : "script.my_script_name" }
Everywhere I try to call this url with the token and body as above it works fine.
But not with Node.Js, I always get one:
“401: Unauthorized”
Has anyone ever experienced this?
Thank you in advance for reading my problem.