diff --git a/packages/cli/src/CredentialsHelper.ts b/packages/cli/src/CredentialsHelper.ts index 4fd8295ce1fa4..2851638360576 100644 --- a/packages/cli/src/CredentialsHelper.ts +++ b/packages/cli/src/CredentialsHelper.ts @@ -224,7 +224,7 @@ export class CredentialsHelper extends ICredentialsHelper { node: INode, defaultTimezone: string, ): string { - if (parameterValue.charAt(0) !== '=') { + if (typeof parameterValue !== 'string' || parameterValue.charAt(0) !== '=') { return parameterValue; } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index f9a32fe78f25c..ec78d8a1dc653 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -825,15 +825,31 @@ function convertN8nRequestToAxios(n8nRequest: IHttpRequestOptions): AxiosRequest async function httpRequest( requestOptions: IHttpRequestOptions, ): Promise { - const axiosRequest = convertN8nRequestToAxios(requestOptions); + let axiosRequest = convertN8nRequestToAxios(requestOptions); if ( axiosRequest.data === undefined || (axiosRequest.method !== undefined && axiosRequest.method.toUpperCase() === 'GET') ) { delete axiosRequest.data; } + let result: AxiosResponse; + try { + result = await axios(axiosRequest); + } catch (error) { + if (requestOptions.auth?.sendImmediately === false) { + const { response } = error; + if (response?.status !== 401 || !response.headers['www-authenticate']?.includes('nonce')) { + throw error; + } + + const { auth } = axiosRequest; + delete axiosRequest.auth; + axiosRequest = digestAuthAxiosConfig(axiosRequest, response, auth); + result = await axios(axiosRequest); + } + throw error; + } - const result = await axios(axiosRequest); if (requestOptions.returnFullResponse) { return { body: result.data, @@ -842,6 +858,7 @@ async function httpRequest( statusMessage: result.statusText, }; } + return result.data; } diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index e18299e79f7cc..6c1b687b3f792 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -172,6 +172,7 @@ export interface IRequestOptionsSimplified { auth?: { username: string; password: string; + sendImmediately?: boolean; }; body: IDataObject; headers: IDataObject; @@ -182,6 +183,7 @@ export interface IRequestOptionsSimplifiedAuth { auth?: { username: string; password: string; + sendImmediately?: boolean; }; body?: IDataObject; headers?: IDataObject; @@ -501,6 +503,7 @@ export interface IHttpRequestOptions { auth?: { username: string; password: string; + sendImmediately?: boolean; }; disableFollowRedirect?: boolean; encoding?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';