How do I send a file in Content-Type: multipart/form-data mode?

I can’t send a file via the HTTP Request node in multipart/form-data mode

I get the data on the web hack and create a csv file from it via the Spreadsheet File node. Next, I need to send this file in the form of a POST request, but I can’t send it in the request body (the api won’t accept the data).

Please tell me how to transfer a file in the form of a POST request?

Below I have attached an example of the correct query:

POST https://api.site.net/management/v1/counter/{counterId}/offline_conversions/upload?client_id_type=CLIENT_ID
Content-Type: multipart/form-data; boundary=------------------------7zDUQOAIAE9hEWoV
Context-Length: 253

--------------------------7zDUQOAIAE9hEWoV
Content-Disposition: form-data; name="file"; filename="data.csv"
Content-Type: text/csv

ClientId,Target,DateTime,Price,Currency
133591247640966458,GOAL1,1481718166,123.45,RUB
133591247640966458,GOAL2,1481718142,678.90,RUB
133591247640966458,GOAL3,1481718066,123.45,RUB
579124169844706072,GOAL3,1481718116,678.90,RUB
148059425477661429,GOAL2,1481718126,123.45,RUB
148059425477661429,GOAL3,1481714026,678.90,RUB
--------------------------7zDUQOAIAE9hEWoV--

Information on your n8n setup

  • n8n version: 1.22.6
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 20.04

Hey @Danilov_Vovka,

In the HTTP Request node for the body you can specify Form-Data then use the name of the binary item for the input data field name in the image below it is data

The workflow below shows how you can do this.

The API cannot accept the file passed to the body. It expects Content-Type: multipart/form-data;

When I checked the request on webhook.site doing it like that was sending it as multipart/form-data did you give it a try?


For some reason, I have content-type text/csv

Here is a screenshot of the node itself:


I think I found an error in

the body you can specify Form-Data then use the name of the binary item for the input data field name in the image below it is data

I’ll check and let you know the results.

1 Like

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