Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106088

How to send variable to script over Rest API

$
0
0

@farstreet wrote:

I have created a TTS script in my configuration that needs 3 variables to run properly. When calling this script in my automations, I simply do:

    - service: script.google_home_notification
      data:
        exclude_bedroom_when_sleeping: "yes"
        language: "en"
        message: "this is a test"

Works like a charm. However, I also want to be able to call this script via the REST API but I can’t seem to get the URL (see below) correct, I keep on getting 400: Bad Request back. When I do a POST to a script without variables, that works fine, it executes without any problem.

curl --location --request POST 'MYURL/api/services/script/turn_on' \
--header 'Authorization: Bearer MYTOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
	"entity_id": "script.google_home_notification",
	"exclude_bedroom_when_sleeping":"yes",
	"language":"en",
	"message":"this is a test"		
}'

I tried variations that included data, data_template, service_data, etc… but without any success…
Searched Google and this community for hours already… Kinda expect that it’s going to be a small stupid error but I just can’t find it… Help :slight_smile:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 106088

Trending Articles