added option to specify HTTP method

This commit is contained in:
jokob.sk
2022-10-02 21:52:46 +11:00
parent 43bc86becf
commit 32d5455f45
2 changed files with 8 additions and 1 deletions

View File

@@ -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)

View File

@@ -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
#-----------------------