-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
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:
n8n-openapi-node/src/n8n/SchemaToINodeProperties.ts
Lines 171 to 175 in c08043b
| 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