Skip to content

[Feature Request] Support multipart/form-data #24

@mattcoulter7

Description

@mattcoulter7

Hey,

This is an awesome package btw.

I need to upload files as multipart/form-data.

Use Case

        "/api/files": {
            "post": {
                "tags": [
                    "files"
                ],
                "summary": "Create File",
                "description": "Upload a file",
                "operationId": "create_file_api_files_post",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "$ref": "#/components/schemas/Body_create_file_api_files_post"
                            }
                        }
                    }
                },
            }
        }

I can see here, you are strictly not accepting anything other than application/json:

const regexp = /application\/json.*/
const content = findKey(body.content, regexp)
if (!content) {
throw new Error(`No '${regexp}' content found`);
}


Logs

Expected:

[04:01:59.227] WARN (6): Failed to parse request body
    operation: {
      "pattern": "/api/files",
      "method": "post",
      "operationId": "create_file_api_files_post"
    }
    error: "Error: No '/application\\/json.*/' content found"

And in the n8n UI, we will see a message like:

POST /api/files

There's no body available for request, kindly use HTTP Request node to send body

Unfortunately, I cannot use the HTTP Request Node, as my custom credential is not linked to it. But also, it feels a lot cleaner to use the custom node.


Implementation

Of course, there is no schema for the request to with form-data, so the way that n8n tends to support this is by specifying a Binary Data Input Field Name. See the HTTP Request V3.

https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/#form-data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions