Forward webhook with automation help

Hi guys/gals,

I’m trying to use webhooks and automation to forward an incoming webhook with it’s payload but I just can’t seem to get it working.

Configuration in yaml:

shell_command:
  forwardjson: >
    curl -X POST -H 'Content-Type: application/json' -d '{{ data }}' {{ url }}

Automation:
Trigger webhook + my webhook ID

Action:

data:
  data: trigger.json
  url: 'http://MyEndpoint:port'
service: shell_command.forwardjson

ive tried variations of {{trigger.json}}/{trigger.json}, trigger.data/trigger.payload
message:
data_template:
value_template:
following the docs here

I either get the literal value “trigger.json” in the receiving end or an error in homeassistant from the shell component (returned error code 3 or error code 6 NoneType: None)

this is an example curl I sent to homeassistant

curl --request POST \
  --url http://HomeAsisstant:8123/api/webhook/MyWebhookID\
  --header 'content-type: application/json' \
  --data '{
	"data":"Forwarded"
}'

Any ideas what I’m doing wrng?

I would think a data_template is needed. I haven’t done this myself, but the following might give you some ideas:

In particular, you probably want the template to look like '{{ trigger.json.data }}'.
So maybe something like:

data_template:
  data: '{{ trigger.json.data }}'
  .....
1 Like

Hey,

OK after some tweaking this is now working

data_template:
  data: '{{ trigger.json }}'
  url: 'mywebhook'
service: shell_command.forwardjson

Thanks!!!