From a9bf3d022661f0a3ee9c4980dd1437bb3aa84499 Mon Sep 17 00:00:00 2001 From: Nick Kasten Date: Tue, 5 Mar 2019 09:55:21 -0600 Subject: [PATCH] add multipart/form-data support to http request node --- nodes/core/io/21-httprequest.html | 13 +++++++++- nodes/core/io/21-httprequest.js | 40 ++++++++++++++++++------------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/nodes/core/io/21-httprequest.html b/nodes/core/io/21-httprequest.html index f3c4c0228..42c0cbc34 100644 --- a/nodes/core/io/21-httprequest.html +++ b/nodes/core/io/21-httprequest.html @@ -129,7 +129,18 @@

If msg.payload is an Object, the node will automatically set the content type of the request to application/json and encode the body as such.

To encode the request as form data, msg.headers["content-type"] should be set to application/x-www-form-urlencoded.

- +

For form-based file uploads, some services require that msg.headers["content-type"] be set to multipart/form-data. + To construct msg.payload for this type of request, use the following structure and substitue the KEY, DATA, and FILENAME + values for your own. +

req.formData = { 
+    KEY: { 
+        value: DATA, 
+        options: { 
+            filename: ‘FILENAME’ 
+        } 
+    } 
+}
+