mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(HTTP Request Node): Support for dot notation in JSON body
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import type { IDataObject, INodeExecutionData, IOAuth2Options } from 'n8n-workflow';
|
||||
import type { OptionsWithUri } from 'request-promise-native';
|
||||
|
||||
import set from 'lodash.set';
|
||||
|
||||
export type BodyParameter = { name: string; value: string };
|
||||
|
||||
export type IAuthDataSanitizeKeys = {
|
||||
[key: string]: string[];
|
||||
};
|
||||
@@ -130,3 +134,25 @@ export const binaryContentTypes = [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/x-7z-compressed',
|
||||
];
|
||||
|
||||
export type BodyParametersReducer = (
|
||||
acc: IDataObject,
|
||||
cur: { name: string; value: string },
|
||||
) => IDataObject;
|
||||
|
||||
export const prepareRequestBody = (
|
||||
parameters: BodyParameter[],
|
||||
bodyType: string,
|
||||
version: number,
|
||||
defaultReducer: BodyParametersReducer,
|
||||
) => {
|
||||
if (bodyType === 'json' && version >= 4) {
|
||||
return parameters.reduce((acc, entry) => {
|
||||
const value = entry.value;
|
||||
set(acc, entry.name, value);
|
||||
return acc;
|
||||
}, {} as IDataObject);
|
||||
} else {
|
||||
return parameters.reduce(defaultReducer, {});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user