Open s1061429 opened 9 months ago
For rest
type, schema is same as REST in Home Assistant.
The difference is that value_template
is added in this integration, so that you can modify API result.
Form data
- spec:
name: get_your_data
description: Get your data
parameters:
type: object
properties:
dummy:
type: string
description: Nothing.
function:
type: rest
method: POST
resource: "https://YOUR_POST_API"
payload: "foo=foo&bar=bar"
headers:
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
value_template: '{{value_json}}'
JSON
- spec:
name: get_your_data
description: Get your data
parameters:
type: object
properties:
dummy:
type: string
description: Nothing.
function:
type: rest
method: POST
resource: "https://YOUR_POST_API"
payload: >-
{"foo": "foo", "bar": "bar"}
headers:
"Content-Type": "application/json; charset=utf-8"
value_template: '{{value_json}}'
Thanks! So in that case no templating is available for the payload? Like
- spec:
name: get_your_data
description: Get your data
parameters:
type: object
properties:
foo:
type: string
description: Some interesting payload variable.
function:
type: rest
method: POST
resource: "https://YOUR_POST_API"
payload: >-
{"foo": "{{foo}}", "bar": "bar"}
headers:
"Content-Type": "application/json; charset=utf-8"
value_template: '{{value_json}}'
This would be nice to have.
I just realized that rest and scrape of HA doesn't support payload
as a template.
I added payload_template
variable in rest
and scrape
function.
Please try 1.0.3-beta1 version and give a feedback.
Works like a charm! Thanks a lot!
Thanks for this great project! I am trying to do a POST request as a function, but can you provide an example of how to do this? Thanks!