From e39678b54f18c424175ef0c0f8f37c55981b790b Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Thu, 28 Oct 2021 18:09:25 +0200 Subject: [PATCH] :bug: Fixed url params serializing for OAuth1 requests (#2381) --- packages/core/src/NodeExecuteFunctions.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index b34f2ed02d..d6dc5da8ad 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -86,6 +86,12 @@ import { axios.defaults.timeout = 300000; // Prevent axios from adding x-form-www-urlencoded headers by default axios.defaults.headers.post = {}; +axios.defaults.paramsSerializer = (params) => { + if (params instanceof URLSearchParams) { + return params.toString(); + } + return stringify(params, { arrayFormat: 'indices' }); +}; const requestPromiseWithDefaults = requestPromise.defaults({ timeout: 300000, // 5 minutes @@ -413,6 +419,7 @@ async function parseRequestObject(requestObject: IDataObject) { if ( requestObject.json !== false && axiosConfig.data !== undefined && + axiosConfig.data !== '' && !(axiosConfig.data instanceof Buffer) && !allHeaders.some((headerKey) => headerKey.toLowerCase() === 'content-type') ) { @@ -462,6 +469,11 @@ async function proxyRequestToAxios( axiosConfig = Object.assign(axiosConfig, await parseRequestObject(configObject)); + Logger.debug('Proxying request to axios', { + originalConfig: configObject, + parsedConfig: axiosConfig, + }); + return new Promise((resolve, reject) => { axios(axiosConfig) .then((response) => {