mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(HTTP Request Node): Support for dot notation in JSON body
This commit is contained in:
@@ -10,14 +10,17 @@ import type {
|
||||
INodeTypeDescription,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { BINARY_ENCODING, jsonParse, NodeApiError, NodeOperationError, sleep } from 'n8n-workflow';
|
||||
|
||||
import type { OptionsWithUri } from 'request-promise-native';
|
||||
|
||||
import type { IAuthDataSanitizeKeys } from '../GenericFunctions';
|
||||
import type { BodyParameter, IAuthDataSanitizeKeys } from '../GenericFunctions';
|
||||
|
||||
import {
|
||||
binaryContentTypes,
|
||||
getOAuth2AdditionalParameters,
|
||||
prepareRequestBody,
|
||||
replaceNullValues,
|
||||
sanitizeUiMessage,
|
||||
} from '../GenericFunctions';
|
||||
@@ -35,7 +38,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
subtitle: '={{$parameter["method"] + ": " + $parameter["url"]}}',
|
||||
version: 3,
|
||||
version: [3, 4],
|
||||
defaults: {
|
||||
name: 'HTTP Request',
|
||||
color: '#2200DD',
|
||||
@@ -879,6 +882,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
|
||||
const fullResponseProperties = ['body', 'headers', 'statusCode', 'statusMessage'];
|
||||
|
||||
@@ -960,9 +964,11 @@ export class HttpRequestV3 implements INodeType {
|
||||
const sendBody = this.getNodeParameter('sendBody', itemIndex, false) as boolean;
|
||||
const bodyContentType = this.getNodeParameter('contentType', itemIndex, '') as string;
|
||||
const specifyBody = this.getNodeParameter('specifyBody', itemIndex, '') as string;
|
||||
const bodyParameters = this.getNodeParameter('bodyParameters.parameters', itemIndex, []) as [
|
||||
{ name: string; value: string },
|
||||
];
|
||||
const bodyParameters = this.getNodeParameter(
|
||||
'bodyParameters.parameters',
|
||||
itemIndex,
|
||||
[],
|
||||
) as BodyParameter[];
|
||||
const jsonBodyParameter = this.getNodeParameter('jsonBody', itemIndex, '') as string;
|
||||
const body = this.getNodeParameter('body', itemIndex, '') as string;
|
||||
|
||||
@@ -1094,7 +1100,12 @@ export class HttpRequestV3 implements INodeType {
|
||||
// Get parameters defined in the UI
|
||||
if (sendBody && bodyParameters) {
|
||||
if (specifyBody === 'keypair' || bodyContentType === 'multipart-form-data') {
|
||||
requestOptions.body = bodyParameters.reduce(parametersToKeyValue, {});
|
||||
requestOptions.body = prepareRequestBody(
|
||||
bodyParameters,
|
||||
bodyContentType,
|
||||
nodeVersion,
|
||||
parametersToKeyValue,
|
||||
);
|
||||
} else if (specifyBody === 'json') {
|
||||
// body is specified using JSON
|
||||
if (typeof jsonBodyParameter !== 'object' && jsonBodyParameter !== null) {
|
||||
|
||||
Reference in New Issue
Block a user