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, max_retries=3,
throws=(httpx.HTTPError,), throws=(httpx.HTTPError,),
) )
def send_webhook(url, data, headers, files): def send_webhook(url: str, data: dict | str, headers: dict, files: dict | None):
try: try:
httpx.post( if isinstance(data, dict):
url, httpx.post(
data=data, url,
files=files, json=data,
headers=headers, headers=headers,
).raise_for_status() files=files,
).raise_for_status()
else:
httpx.post(
url,
data=data,
files=files,
headers=headers,
).raise_for_status()
logger.info( logger.info(
f"Webhook sent to {url}", f"Webhook sent to {url}",
) )