Json Authorisation Bearer token


#1

1) Give a description of the problem
trying to turn on a switch via api
Authorisation: Bearer abcdefgh
“entity_id”: “switch.office_subwoofer”
gives 500 error code as response
task not executed

2) What is the expected behaviour?
turn on switch

3) What is happening/not happening?
500 error

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

curl post works from outside the network via online tool

curl -X POST -d ‘{“entity_id”: “switch.office_subwoofer”}’ https://xxxmyhomexxx.duckdns.org/api/services/switch/toggle -H ‘Authorization: Bearer xxxabcdefghxxx’

json works from outside the network via online tool

POST /api/services/switch/toggle HTTP/1.1
Authorization: Bearer xxxabcdefghxxx
Host: xxxmyhomexxx.duckdns.org
Content-Type: application/json
Content-Length: 40

{“entity_id”: “switch.office_subwoofer”}


**

I tried numerours combinations and options in webcore to shuffle the authorisation and entity_id. But all of them gave 500 error as response and the command did not get sent at all.

Given that json works from online tool, it should work in webcore as well.

Can you please help me with how to correctly configure the piston.

Thank you.
Megas


#3

I think all you need to do is create a web request, enter the URL, choose POST, leave the body as JSON, under ‘Send variables’ select ‘Variable’ and choose entity_id, and under ‘Authorization Header’ section select ‘Variable’ and Choose Authorization.