mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
✨ Make it possible to send Form-Data with HttpRequest-Node
This commit is contained in:
parent
a0fd9b2065
commit
ea6ec1aa6c
|
@ -187,7 +187,6 @@ export class HttpRequest implements INodeType {
|
||||||
'file',
|
'file',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
description: 'Name of the binary property to which to<br />write the data of the read file.',
|
description: 'Name of the binary property to which to<br />write the data of the read file.',
|
||||||
},
|
},
|
||||||
|
@ -207,6 +206,35 @@ export class HttpRequest implements INodeType {
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Option',
|
||||||
default: {},
|
default: {},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Body Content Type',
|
||||||
|
name: 'bodyContentType',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/requestMethod': [
|
||||||
|
'POST',
|
||||||
|
'PUT',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'JSON',
|
||||||
|
value: 'json'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Form-Data Multipart',
|
||||||
|
value: 'multipart-form-data'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Form Urlencoded',
|
||||||
|
value: 'form-urlencoded'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'json',
|
||||||
|
description: 'Content-Type to use to send body parameters.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Full Response',
|
displayName: 'Full Response',
|
||||||
name: 'fullResponse',
|
name: 'fullResponse',
|
||||||
|
@ -546,6 +574,17 @@ export class HttpRequest implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change the way data get send in case a different content-type than JSON got selected
|
||||||
|
if (['POST', 'PUT'].includes(requestMethod)) {
|
||||||
|
if (options.bodyContentType === 'multipart-form-data') {
|
||||||
|
requestOptions.formData = requestOptions.body;
|
||||||
|
delete requestOptions.body;
|
||||||
|
} else if (options.bodyContentType === 'form-urlencoded') {
|
||||||
|
requestOptions.form = requestOptions.body;
|
||||||
|
delete requestOptions.body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add credentials if any are set
|
// Add credentials if any are set
|
||||||
if (httpBasicAuth !== undefined) {
|
if (httpBasicAuth !== undefined) {
|
||||||
requestOptions.auth = {
|
requestOptions.auth = {
|
||||||
|
|
Loading…
Reference in a new issue