I have a collection with a single request in it. I’m using a .csv with collection runner to execute the request once per line in the .csv. The first column in the .csv is “Document ID”, and that’s the only variable I’m using from the .csv.
However, at the bottom of the .csv is a blank line followed by a few lines that aren’t pertinent to the running of the collection.
I’d like the collection to see the blank line (pm.collectionVariables.get(‘Document ID’) == ‘’) and stop executing.
Any suggestions on the best way to do that?
Not sure this is possible, as setNextRequest(null) only sets the request that will run next.
It doesn’t trigger immediately.
Therefore, you can check if the element is empty in a pre-request but its still going to run that request.
My suggestion would be to transform the CSV file so its in the correct format to start with. (This is always my suggestion for this type of task, as Postman is not an ETL tool).
I know its another language, but I’d probably do this in PowerShell first as it has native cmdlet support for CSV files. Import the CSV, filter out blank lines and the other lines and then Export-CSV.
Get PowerShell to pick up the file from the source, and then save it to the folder that Postman will pick it up from.