Make body optional
This commit is contained in:
parent
e16fea8999
commit
d14cf22f33
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue