Hi,
I am trying to use the rest_command integration to send a POST request to an external server and I want to use the data
contents as the payload.
I can find everywhere to construct the payload using attributes passed in using data
but I basically want to take the whole data
content and convert it to a JSON payload, but I can’t find any info on how to achieve this…
I want to pass run something like the following:
service: rest_command.e_script
data:
id: "1234"
params:
entity_id: "light.lounge_1"
Currently I can pull attributes and construct the payload in the configuration, then for the params
at the endpoint do some JSON.parse and replace all single quotes with double quotes
rest_command:
e_script:
url: http://192.168.2.37:9001/script
method: POST
payload: '{ "id": "{{ id }}", "params": "{{ params }}" }'
content_type: 'application/json; charset=utf-8'
But in reality I just the the data
to be converted to JSON as-is and pass straight into payload… something like payload: {{ data }}
This will allow me to not have to pre-determine a payload schema and pull straight from the service call
And help would be great, thanks!