From 32d5455f45873bdcf1f0a08200173cef97fb7a7d Mon Sep 17 00:00:00 2001 From: "jokob.sk" Date: Sun, 2 Oct 2022 21:52:46 +1100 Subject: [PATCH] added option to specify HTTP method --- back/pialert.py | 8 +++++++- config/pialert.conf | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/back/pialert.py b/back/pialert.py index b318b6ad..63631e41 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1608,6 +1608,12 @@ def send_webhook (_json, _html): except NameError: # variable not defined, use a default webhookPayload = 'json' + # HTTP request method (GET, POST...) + try: + webhookRequestMethod = WEBHOOK_REQUEST_METHOD + except NameError: # variable not defined, use a default + webhookRequestMethod = 'GET' + # use data type based on specified payload type if webhookPayload == 'json': payloadData = _json @@ -1631,7 +1637,7 @@ def send_webhook (_json, _html): curlParams = ["curl","-i","-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), _WEBHOOK_URL] else: _WEBHOOK_URL = WEBHOOK_URL - curlParams = ["curl","-i","-X", "GET" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), _WEBHOOK_URL] + curlParams = ["curl","-i","-X", webhookRequestMethod ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), _WEBHOOK_URL] # execute CURL call p = subprocess.Popen(curlParams, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) diff --git a/config/pialert.conf b/config/pialert.conf index 0f997090..5be6f6d3 100644 --- a/config/pialert.conf +++ b/config/pialert.conf @@ -39,6 +39,7 @@ WEBHOOK_URL = 'http://n8n.local:5555/webhook-test/aaaaaaaa-aaaa-aaaa # supported values: 'json' or 'html' # e.g.: for discord use 'html' WEBHOOK_PAYLOAD = 'json' +WEBHOOK_REQUEST_METHOD = 'GET' # POST, GET... # Apprise settings #-----------------------