Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook data "trigger.json" is no valid JSON #28493

sibbl opened this issue Nov 3, 2019 · 2 comments


Copy link

@sibbl sibbl commented Nov 3, 2019

Home Assistant release with the issue:

Last working Home Assistant release (if known):

Operating environment ( on RPi 4


Description of problem:
I'm trying to set up a generic webhook automation, which forwards all received data to Node Red.

However, when sending valid JSON to my webhook, I receive a string {'hello':'world'} over at Node Red. JSON.parse fails there as it's no valid json (it requires double quotes).

I'm using the following action in my automation:

  - data_template:
        data: '{{}}'
        webhook_id: '{{trigger.webhook_id}}'
        json: '{{trigger.json}}'
        query: '{{trigger.query}}'
    service: rest_command.node_red

I'm not sure if necessary, but my rest_command looks like

    url: http://localhost:1880/endpoint/nodered
        method: POST
        username: !secret node_red_http_node_username
        password: !secret node_red_http_node_password
        payload: '{{ data | tojson }}'
        content_type:  'application/json; charset=utf-8'

Additional information:

Furthermore, I only get some stringified output of MultiDictProxy for the data and query fields. In my eyes this should be either raw content (for data) or a JSON object (query), or at least something which I can pass through the |tojson filter in the template.


This comment has been minimized.

Copy link

@sibbl sibbl commented Nov 4, 2019

For reproducability, I've shared my whole integration over at the HA Community:

To reproduce this error, go into the Node Red subflow's "function" node and remove the replace call which replaces single quotes by double quotes. It will fail on the json field.


This comment has been minimized.

Copy link

@sibbl sibbl commented Nov 4, 2019

A quick follow up since I've tried to solve converting the MultiDictProxy into JSON as well.

It might be only necessary to change this line


result["json"] = await request.json()


result["json"] = json.dumps(await request.json())

or similar. I've no idea how this works in Python and especially with aiohttp, but maybe it helps ¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.