From cba2874c2e9fe9170f9f65f436384de7db7df6b8 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 21 Oct 2021 15:12:15 -0500 Subject: [PATCH] :bug: Fix useQuerystring in combination with x-www-form-urlencoded #2348 --- packages/core/src/NodeExecuteFunctions.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 2854f618ec..9aa1cf3e8d 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -162,16 +162,19 @@ async function parseRequestObject(requestObject: IDataObject) { // and also using formData. Request lib takes precedence for the formData. // We will do the same. // Merge body and form properties. - // @ts-ignore - axiosConfig.data = - typeof requestObject.body === 'string' - ? requestObject.body - : new URLSearchParams( - Object.assign(requestObject.body || {}, requestObject.form || {}) as Record< - string, - string - >, - ); + if (typeof requestObject.body === 'string') { + axiosConfig.data = requestObject.body; + } else { + const allData = Object.assign(requestObject.body || {}, requestObject.form || {}) as Record< + string, + string + >; + if (requestObject.useQuerystring === true) { + axiosConfig.data = stringify(allData, { arrayFormat: 'repeat' }); + } else { + axiosConfig.data = stringify(allData); + } + } } else if (contentType && contentType.includes('multipart/form-data') !== false) { if (requestObject.formData !== undefined && requestObject.formData instanceof FormData) { axiosConfig.data = requestObject.formData;