From d838c2c816855699f990a725bc5b4f2b6f72a504 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 11 Jul 2024 11:49:19 +0200 Subject: [PATCH] :bug: Fix http req body type issue --- .../integrations/webhook/executeWebhookBlock.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts index ada16d02d..5ad41e07a 100644 --- a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts +++ b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts @@ -197,13 +197,11 @@ export const executeWebhook = async ( if (isFormData && isJson) body = parseFormDataBody(body as object) - const request = { + const baseRequest = { url, method, headers: headers ?? {}, ...(basicAuth ?? {}), - json: !isFormData && body && isJson ? body : undefined, - body: body && (isFormData || !isJson) ? body : undefined, timeout: isNotDefined(env.CHAT_API_TIMEOUT) ? false : params.timeout && params.timeout !== defaultTimeout @@ -211,7 +209,13 @@ export const executeWebhook = async ( : isLongRequest ? maxTimeout * 1000 : defaultTimeout * 1000, - } satisfies Options & { url: string; body: any } + } satisfies Options & { url: string } + + const request = body + ? !isFormData && isJson + ? { ...baseRequest, json: body } + : { ...baseRequest, body } + : baseRequest try { const response = await ky(request.url, omit(request, 'url'))