From 8bc369dd40836472502dc7b36c503a04db3f480c Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:46:00 +0300 Subject: [PATCH] fix(Respond to Webhook Node): JSON output from expression fix (#7294) Github issue / Community forum post (link here to close automatically): https://github.com/n8n-io/n8n/issues/7077 --- .../nodes/RespondToWebhook/RespondToWebhook.node.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts index f3c42a15ab0fe..9d4b81d455aa3 100644 --- a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts +++ b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts @@ -206,9 +206,13 @@ export class RespondToWebhook implements INodeType { if (respondWith === 'json') { const responseBodyParameter = this.getNodeParameter('responseBody', 0) as string; if (responseBodyParameter) { - responseBody = jsonParse(responseBodyParameter, { - errorMessage: "Invalid JSON in 'Response Body' field", - }); + if (typeof responseBodyParameter === 'object') { + responseBody = responseBodyParameter; + } else { + responseBody = jsonParse(responseBodyParameter, { + errorMessage: "Invalid JSON in 'Response Body' field", + }); + } } } else if (respondWith === 'firstIncomingItem') { responseBody = items[0].json;