mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
added option to specify HTTP method
This commit is contained in:
@@ -1608,6 +1608,12 @@ def send_webhook (_json, _html):
|
|||||||
except NameError: # variable not defined, use a default
|
except NameError: # variable not defined, use a default
|
||||||
webhookPayload = 'json'
|
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
|
# use data type based on specified payload type
|
||||||
if webhookPayload == 'json':
|
if webhookPayload == 'json':
|
||||||
payloadData = _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]
|
curlParams = ["curl","-i","-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), _WEBHOOK_URL]
|
||||||
else:
|
else:
|
||||||
_WEBHOOK_URL = WEBHOOK_URL
|
_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
|
# execute CURL call
|
||||||
p = subprocess.Popen(curlParams, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(curlParams, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ WEBHOOK_URL = 'http://n8n.local:5555/webhook-test/aaaaaaaa-aaaa-aaaa
|
|||||||
# supported values: 'json' or 'html'
|
# supported values: 'json' or 'html'
|
||||||
# e.g.: for discord use 'html'
|
# e.g.: for discord use 'html'
|
||||||
WEBHOOK_PAYLOAD = 'json'
|
WEBHOOK_PAYLOAD = 'json'
|
||||||
|
WEBHOOK_REQUEST_METHOD = 'GET' # POST, GET...
|
||||||
|
|
||||||
# Apprise settings
|
# Apprise settings
|
||||||
#-----------------------
|
#-----------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user