From d14cf22f33e0de7c5c63f214e07a6c9cbefb3e90 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 24 Sep 2018 20:18:49 +0200 Subject: [PATCH] Make body optional --- homeassistant/components/webhook.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/webhook.py b/homeassistant/components/webhook.py index 5ae20230d..990fdaca9 100644 --- a/homeassistant/components/webhook.py +++ b/homeassistant/components/webhook.py @@ -3,6 +3,7 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/webhook/ """ +import json import logging from aiohttp.web import Response @@ -75,8 +76,9 @@ class WebhookView(HomeAssistantView): 'Received message for unregistered webhook %s', webhook_id) return Response(status=200) + body = await request.text() try: - data = await request.json() + data = json.load(body) if body else {} except ValueError: _LOGGER.warning( 'Received webhook %s with invalid JSON', webhook_id)