Fix: json-encode WH data if specified as params

This commit is contained in:
shamoon 2025-01-17 17:22:21 -08:00
parent cd50f20a20
commit f3c0cf3886

View File

@ -573,14 +573,22 @@ def run_workflows_updated(sender, document: Document, logging_group=None, **kwar
max_retries=3,
throws=(httpx.HTTPError,),
)
def send_webhook(url, data, headers, files):
def send_webhook(url: str, data: dict | str, headers: dict, files: dict | None):
try:
httpx.post(
url,
data=data,
files=files,
headers=headers,
).raise_for_status()
if isinstance(data, dict):
httpx.post(
url,
json=data,
headers=headers,
files=files,
).raise_for_status()
else:
httpx.post(
url,
data=data,
files=files,
headers=headers,
).raise_for_status()
logger.info(
f"Webhook sent to {url}",
)