How to write a subset of fields to a CSV file

Using the “HTTP Request” node I’m pulling records with ~25 fields. I only want to pull 6 of those fields and write the data to a CSV file. The API I’m pulling does not allow field selections. I’m a n8n noob and am not sure how to build the workflow for this…specifically what nodes to use. Any help is greatly appreciated.

I’m using the current desktop client.

Hi there! You can use the “Keep only set” option on the Set node to filter out unwanted properties.

Thank you drudge…will try that and post again if I can’t make it work.

I’m sorry, but I can find no way to pass on the data from just 6 of the properties returned from the HTTP Request node using the Set node. I’ve read the Set node docs and played with with adding various “Values to Set” entries and the only thing the Set node outputs is the values I enter in the “Values to Set” section. Any idea what I’m doing wrong?

Is it possible to share a workflow so I can better understand what you’re trying?

If you use the Set node after your HTTP Request node with the “Keep Only Set” option, you can specify the 6 fields you’d like in the Values to Set. The actual value for these properties should be an expression that maps to the fields from the HTTP Request node.

Based on this, I think I understand…I’ll see what I can do. Much thx!

I still cannot make the Set node output more than 1 record.

I cannot share the workflow due to exposing my clients API endpoint.

However, here is the flow: Start–>HTTP Request which I limit to the top 10 records ($top = 10) -->Set node:

Keep Only Set = true
I set “Values to Set”–>“Name” to PartNumber and “Value”–>“Add Expression” to select one field from “Current Node”–>“Input Data”–>“JSON”–>“0”–>“PartNumber”

If I execute this workflow only 1 PartNumber shows up in the output. I assume the Set node should output all 10 of the records from the left hand side “Input” section?

This was a test with only one field…I need to output six fields from approximately 1,650 records.

I assume I must be doing something wrong. The above describes the workflow. If I need to I guess I could save the workflow without the API endpoint URL?

If you could post the output from your HTTP Request node so we can see the structure of the response, that might help.

I suspect the result of the HTTP Request node may be a single item that contains an array property with 10 items that would first need to be split out before you pass it to the Set node.

The output of the HTTP Request node lists 1 item and shows items 0 thru 9 separately each enclose within {} brackets.

This might be it…I’ll play with breaking each item out and see if that works.

Thx again!

Here is a partial screen cap of the HTTP Request node output…not sure where to go now?

I figured it out - thank you very much!!

1 Like