HTTP POST multipart-form-data via msg.payload

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

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

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)


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

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

[
    {
        "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

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

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

you make to understand http builin request node thanks a lot

my flow is ready thanks a lot

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