From 54a4970a4c5c3b518d97145609cbc53df63ce886 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 8 Oct 2024 09:48:38 +0200 Subject: [PATCH] Custom JSON/POST Notifications - Log when it could not apply the application/json content-type header --- changedetectionio/apprise_plugin/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/changedetectionio/apprise_plugin/__init__.py b/changedetectionio/apprise_plugin/__init__.py index 93c382fa..ecca929f 100644 --- a/changedetectionio/apprise_plugin/__init__.py +++ b/changedetectionio/apprise_plugin/__init__.py @@ -1,5 +1,6 @@ # include the decorator from apprise.decorators import notify +from loguru import logger @notify(on="delete") @notify(on="deletes") @@ -64,10 +65,12 @@ def apprise_custom_api_call_wrapper(body, title, notify_type, *args, **kwargs): auth = (URLBase.unquote(results.get('user'))) # Try to auto-guess if it's JSON + h = 'application/json; charset=utf-8' try: json.loads(body) - headers['Content-Type'] = 'application/json; charset=utf-8' + headers['Content-Type'] = h except ValueError as e: + logger.warning(f"Could not automatically add '{h}' header to the {kwargs['meta'].get('schema')}:// notification because the document failed to parse as JSON: {e}") pass r(results.get('url'),