Open scripts with HomeAssistant API

Why is this not working?
http://hassio:8123/api/services/scripts/camdetecon?api_password=1234
405: Method Not Allowed

Thanks

Your question is quite unclear. What are you trying to do?

If you are trying to run script.camdetecon, you may try the curl command:

curl -X POST -H “Content-Type: application/json” -H “x-ha-access:1234” -d ‘{“entity_id”:“script.camdetecon”}’ http://hassio:8123/api/services/script/turn_on

1 Like

I try to run script.camdetecon

This is what I had to do to run a script via curl. Mine is called MyTestScript

image

image

1- Create the script in the webUI under ConfigurationScripts+Add Script

2- Once you create the script, note it’s entity ID. You can find this in the URL of the script when you are editing it, or by clicking on the :information_source: button near the script in the list, or by querying the /api/services endpoint and looking for it under "domain": "script". Mine is script.mytestscript

3- Finally, run curl with the following syntax:

curl -X POST -H "Authorization: Bearer XXX" -d '{"entity_id": "script.mytestscript"}' http://<ip>:8123/api/services/script/turn_on 

I got the Auth token by creating one under the “Long-Lived Access Tokens” option under my user’s profile.