Generate the CSV file name and pass CSV file as part of Body to HTTP POST

Describe the problem/error/question

I want to achieve 2 things:

  1. generate a CSV file from the JSON received (done successfully). and the name of the CSV file should be generated from one of the field in JSON (could not find a way to set the name of the file dynamically - screenshot below)
  2. Now that the CSV file is generated, I want to post this file to an API via Post method as part of ‘body>raw’ and the name to be passed in query string. cant figure out how to extract the name of the file from input of previous step and how to extract and populate the csv body in the post body ?

What is the error message (if any)?

Have already tried using expressions for generating the name of the file but it gives the following error…

Please share your workflow


(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: n8n cloud
  • Database (default: SQLite): NA
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • **Operating system:**n n8n cloud

I have managed to name the file dynamically, however reading the content of CSV is just not working. no matter what variable / code I use, it only returns the following rather than the actual CSV content. can somebody please help in reading the actual content of CSV file to push it to HTTP

{“data”:{“mimeType”:“text/csv” fileType:“text” fileExtension:“csv” data:“filesystem-v2” fileName:“File.csv” id:“filesystem-v2:workflows/EjAvJZSBs9gNc11k/executions/187/binary_data/5d30750f-8636-4958-a2f8-34dc4a7c4320” fileSize:“1.39 kB”}}

@vikram , here’s how you could do it


  • Dedicated filename could be given under “Options” of Convert to File node
  • To actually send the file to the API endpoint via POST, HTTP Request node has to use “Body Content Type” as Binary File.
  • To add the filename to the query string you need to reference $ as opposed to $json...
1 Like

Thank you @ihortom that works absolutely perfect.

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