mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Merge branch 'raw-for-http-node'
This commit is contained in:
commit
cf1ca8703b
|
@ -139,13 +139,16 @@ export class EmailSend implements INodeType {
|
||||||
host: credentials.host as string,
|
host: credentials.host as string,
|
||||||
port: credentials.port as number,
|
port: credentials.port as number,
|
||||||
secure: credentials.secure as boolean,
|
secure: credentials.secure as boolean,
|
||||||
// @ts-ignore
|
|
||||||
auth: {
|
|
||||||
user: credentials.user,
|
|
||||||
pass: credentials.password,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(credentials.user || credentials.password) {
|
||||||
|
// @ts-ignore
|
||||||
|
connectionOptions.auth = {
|
||||||
|
user: credentials.user,
|
||||||
|
pass: credentials.password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (options.allowUnauthorizedCerts === true) {
|
if (options.allowUnauthorizedCerts === true) {
|
||||||
connectionOptions.tls = {
|
connectionOptions.tls = {
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
|
|
|
@ -196,11 +196,11 @@ export class HttpRequest implements INodeType {
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'JSON Parameters',
|
displayName: 'JSON/RAW Parameters',
|
||||||
name: 'jsonParameters',
|
name: 'jsonParameters',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
description: 'If the query and/or body parameter should be set via the UI or raw as JSON',
|
description: 'If the query and/or body parameter should be set via the value-key pair UI or JSON/RAW',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -228,6 +228,10 @@ export class HttpRequest implements INodeType {
|
||||||
name: 'JSON',
|
name: 'JSON',
|
||||||
value: 'json'
|
value: 'json'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'RAW/Custom',
|
||||||
|
value: 'raw'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Form-Data Multipart',
|
name: 'Form-Data Multipart',
|
||||||
value: 'multipart-form-data'
|
value: 'multipart-form-data'
|
||||||
|
@ -240,6 +244,24 @@ export class HttpRequest implements INodeType {
|
||||||
default: 'json',
|
default: 'json',
|
||||||
description: 'Content-Type to use to send body parameters.',
|
description: 'Content-Type to use to send body parameters.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'MIME Type',
|
||||||
|
name: 'bodyContentCustomMIMEType',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
placeholder: 'text/xml',
|
||||||
|
description: 'Specify the mime type for raw/custom body type',
|
||||||
|
required: false,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/requestMethod': [
|
||||||
|
'PATCH',
|
||||||
|
'POST',
|
||||||
|
'PUT',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Full Response',
|
displayName: 'Full Response',
|
||||||
name: 'fullResponse',
|
name: 'fullResponse',
|
||||||
|
@ -357,7 +379,7 @@ export class HttpRequest implements INodeType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Body parameters as JSON.',
|
description: 'Body parameters as JSON or RAW.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Body Parameters',
|
displayName: 'Body Parameters',
|
||||||
|
@ -554,13 +576,13 @@ export class HttpRequest implements INodeType {
|
||||||
requestOptions[optionData.name] = tempValue;
|
requestOptions[optionData.name] = tempValue;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (typeof requestOptions[optionData.name] !== 'object') {
|
if (typeof requestOptions[optionData.name] !== 'object' && options.bodyContentType !== 'raw') {
|
||||||
// If it is not an object it must be JSON so parse it
|
// If it is not an object && bodyContentType is not 'raw' it must be JSON so parse it
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]);
|
requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`The data in "${optionData.displayName}" is no valid JSON.`);
|
throw new Error(`The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,6 +614,14 @@ export class HttpRequest implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Content Type if any are set
|
||||||
|
if (options.bodyContentCustomMIMEType) {
|
||||||
|
if(requestOptions.headers === undefined) {
|
||||||
|
requestOptions.headers = {};
|
||||||
|
}
|
||||||
|
requestOptions.headers['Content-Type'] = options.bodyContentCustomMIMEType;
|
||||||
|
}
|
||||||
|
|
||||||
// Add credentials if any are set
|
// Add credentials if any are set
|
||||||
if (httpBasicAuth !== undefined) {
|
if (httpBasicAuth !== undefined) {
|
||||||
requestOptions.auth = {
|
requestOptions.auth = {
|
||||||
|
@ -612,6 +642,8 @@ export class HttpRequest implements INodeType {
|
||||||
|
|
||||||
if (responseFormat === 'file') {
|
if (responseFormat === 'file') {
|
||||||
requestOptions.encoding = null;
|
requestOptions.encoding = null;
|
||||||
|
} else if(options.bodyContentType === 'raw') {
|
||||||
|
requestOptions.json = false;
|
||||||
} else {
|
} else {
|
||||||
requestOptions.json = true;
|
requestOptions.json = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue