We are trying to create a CSV file with products from a warehouse.
We have the Json files, we GET all data, but we did not found a way to create a custom CSV with all these informations , Like product name, title, description, price, currency, image1,2,3 , atributes etc
All you need to do is basically build the csv manually in the test script and then send it over to the local server which will write it to a file (server is already included as a github repo which you’ll find in the documentation link above and you can use that for your use-case).
Next, you need to change the fileExtension that is there for the Write Response To File collection,
Right click the Write Response To File collection > Edit > Tests
You can copy this test script inside and move it to your request’s test script.
Now, change the fileExtension to csv and then write your csv data that instead of the response body.
Well, there are 2 solutions that I can think of right now.
Solution 1: (Easier to do)
You’ll need to modify the node server code (the one that you cloned from GitHub) to actually take the file, read the contents and update each csv entry with the correct picture link.
Steps would be:
Write all the product data from your PRODUCTS - Get Info as CSV to the file, also write a blank entry for productLink for each item which will be filled in later.
When you send the second request for picture links i.e PRODUCTS - Get Properties, you just need to parse the csv, update each entry with the correct picture link and then save it back to the file.
Solution 2: (Might take a bit longer but would be a good implementation as also all your data will be stored in the cloud)
You can actually make use of the Google Spreadsheets and it’s APIs to create this whole file over the fly.
Google Spreadsheets API docs: https://developers.google.com/sheets/api/guides/create
You can send the data to the local server which will call the spreadsheet API and write the data directly to a google spreadsheet file.
Then you can directly export your spreadsheet as a CSV.
With such visualizer in place, after sending the request, in the response’s body tab, one can choose the ‘Visualize’ option of display to see the desired formatted csv file, ready to “Select All -> Copy” and paste/use wherever needed (as well into a Google Spreadsheet).
In general I think the new Visualization feature in general, and the given free-form handlebars templates is a very useful functionality and opens up a whole new world for us