# HTTP POST multipart-form-data via msg.payload

**URL:** <https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250>\
**Category:** General\
**Tags:** http-request\
**Created:** [15 December 2022 12:07 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250 "2022-12-15T12:07:11Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [16 December 2022 16:30 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/26 "2022-12-16T16:30:24Z")

</div>

thanks Steve I get the logic cleared that http request node accepts form data please tell how make dynamic form data

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 December 2022 16:31 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/27 "2022-12-16T16:31:10Z")

</div>

> [@nit-cyber](#):
>
> this is my workflow

You are still using the multipart node AND there is none of the flow that I did for you.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e4c7ff8a3c1ac4112a8e3a5827d5e3686f55a7c.png)

> [@nit-cyber](#):
>
> i want to implement using builtin http request node

Then use the flow I prepared for you.  
Replace the inject node with whatever supplies the data.  
Just check that the format going into the HTTP Request is as specified in the help (and in my demo flow)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/34e859ac7f9822b894ddadb2c3f96f4c4aaca6ab.png)

  

> [@nit-cyber](#):
>
> when apikey and workflowid is given the new url is generated  
> this new url is needed to give another http request

So use the dashboard form values in the URL field of the HTTP Request...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/65a974567ba7669b2e5465fd57ec14e793790b60.png)

---

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [16 December 2022 16:33 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/28 "2022-12-16T16:33:47Z")

</div>

thanks for update i am now using the builtin http the workflow code i shared was of previous one which now i am doing with your code

---

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [18 December 2022 16:39 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/29 "2022-12-18T16:39:17Z")

</div>

```auto
[
    {
        "id": "03abc1c38a1de96e",
        "type": "group",
        "z": "cb9f99189bdd5a46",
        "name": "",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "1dbeee2335ce983c",
            "b60232e91211ac73",
            "011454ba69ca8e6f",
            "445af6dfd8f51873",
            "45f3033984aad1db",
            "439da61146b319dc",
            "83c84ccd8fd1794c"
        ],
        "x": 74,
        "y": 619,
        "w": 1202,
        "h": 182
    },
    {
        "id": "1dbeee2335ce983c",
        "type": "http request",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "Post multipart form data",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "Content-Type",
                "keyValue": "",
                "valueType": "multipart/form-data",
                "valueValue": ""
            },
            {
                "keyType": "Accept",
                "keyValue": "",
                "valueType": "application/json",
                "valueValue": ""
            }
        ],
        "credentials": {
            "user": "",
            "password": ""
        },
        "x": 1050,
        "y": 760,
        "wires": [
            [
                "83c84ccd8fd1794c"
            ]
        ]
    },
    {
        "id": "b60232e91211ac73",
        "type": "change",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.api_key",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.workflow_id",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.userfile_url",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 840,
        "y": 760,
        "wires": [
            [
                "1dbeee2335ce983c"
            ]
        ]
    },
    {
        "id": "011454ba69ca8e6f",
        "type": "debug",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "debug 451",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 815,
        "y": 660,
        "wires": [],
        "l": false
    },
    {
        "id": "445af6dfd8f51873",
        "type": "inject",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "formdata",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "payload.api_key",
                "v": "",
                "vt": "str"
            },
            {
                "p": "payload.workflow_id",
                "v": "",
                "vt": "str"
            },
            {
                "p": "headers['Accept']",
                "v": "application/json",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 180,
        "y": 760,
        "wires": [
            [
                "45f3033984aad1db"
            ]
        ]
    },
    {
        "id": "45f3033984aad1db",
        "type": "function",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "the multipart payload",
        "func": "const formData = msg.payload\n\nmsg.payload = {\n api_key: {\n value: formData.api_key || ''\n },\n workflow_id: {\n value: formData.workflow_id || ''\n },\n userfile_url: {\n value: formData.userfile_url || ''\n },\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 760,
        "wires": [
            [
                "439da61146b319dc"
            ]
        ]
    },
    {
        "id": "439da61146b319dc",
        "type": "http request",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "Post multipart form data",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "Content-Type",
                "keyValue": "",
                "valueType": "multipart/form-data",
                "valueValue": ""
            }
        ],
        "credentials": {
            "user": "",
            "password": ""
        },
        "x": 610,
        "y": 760,
        "wires": [
            [
                "b60232e91211ac73",
                "011454ba69ca8e6f"
            ]
        ]
    },
    {
        "id": "83c84ccd8fd1794c",
        "type": "debug",
        "z": "cb9f99189bdd5a46",
        "g": "03abc1c38a1de96e",
        "name": "debug 452",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1215,
        "y": 760,
        "wires": [],
        "l": false
    }
]type or paste code here
this code is working

```

---

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [18 December 2022 16:41 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/30 "2022-12-18T16:41:07Z")

</div>

Hi  
Thanks for help  
now i am able to upload the file

---

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [18 December 2022 16:42 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/31 "2022-12-18T16:42:29Z")

</div>

also the userfile\_url is coming as payload from other flow how to merge to get automatic output.

---

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [18 December 2022 18:15 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/32 "2022-12-18T18:15:05Z")

</div>

you make to understand http builin request node thanks a lot

---

<div class="post-metadata">

**Author:** ![nit-cyber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nit-cyber/32/72630_2.png) [@nit-cyber](https://discourse.nodered.org/u/nit-cyber)\
**Post date:** [19 December 2022 09:56 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/34 "2022-12-19T09:56:48Z")

</div>

my flow is ready thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 January 2023 09:57 UTC](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250/35 "2023-01-02T09:57:38Z")

</div>

Closed on 2 January 2023 09:57 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/http-post-multipart-form-data-via-msg-payload/72250.md?page=1)
