Unable to send binary data with HTTP request node

Hi, I want to send a binary file with a post request, and I need to post it with a form-data multipart option. I am looking for something like we get in postman where we could pass the binary data in form with a key and data being the value of that key.

1 Like

I am very sorry, but multi-part in combination with binary data is currently sadly not supported.

> // Change the way data get send in case a different content-type than JSON got selected
>             if (['PATCH', 'POST', 'PUT'].includes(requestMethod)) {
>                 if (options.bodyContentType === 'multipart-form-data') {
>                     requestOptions.formData = requestOptions.body;
>                     delete requestOptions.body;
>                 } else if (options.bodyContentType === 'form-urlencoded') {
>                     requestOptions.form = requestOptions.body;
>                     delete requestOptions.body;
>                 }
>             }

I want to send the binary file in this format: {“key”: file}, I tried doing this:
requestOptions.formData = {“random_key”:requestOptions.body}
But its giving me error while doing: npm run start
I> am getting following error:

    (node:18056) UnhandledPromiseRejectionWarning: Error: There was an error: Cannot find module 'n8n-core'
    Require stack:
    - C:\Users\Kshitij.bharde\.n8n\custom\HttpNew.node.js
    - D:\nodemation\n8n\packages\cli\dist\src\LoadNodesAndCredentials.js
    - D:\nodemation\n8n\packages\cli\dist\src\index.js
    - D:\nodemation\n8n\packages\cli\dist\commands\execute.js
    - D:\nodemation\n8n\node_modules\@oclif\config\lib\plugin.js
    - D:\nodemation\n8n\node_modules\@oclif\config\lib\config.js
    - D:\nodemation\n8n\node_modules\@oclif\config\lib\index.js
    - D:\nodemation\n8n\node_modules\@oclif\command\lib\command.js
    - D:\nodemation\n8n\node_modules\@oclif\command\lib\index.js
    - D:\nodemation\n8n\packages\cli\bin\n8n
        at Object.error (D:\nodemation\n8n\node_modules\@oclif\errors\lib\index.js:22:17)
        at Start.error (D:\nodemation\n8n\node_modules\@oclif\command\lib\command.js:57:23)
        at D:\nodemation\n8n\packages\cli\commands\start.ts:201:10
    (node:18056) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
    (node:18056) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It seems like it can not find the module n8n-core for some reason and does therefor not start.

So your best bet is to simply execute the lerna command again: lerna bootstrap --hoist