Data File Loop for Variables WITHOUT URL Param Style variable

Hello!

I’m trying to use a data file to loop through a CSV full of record ID’s on a GET request. The URL for the endpoint is something like this

https://myendpoint.test.com/data/{{record_id}}/LogFile

Where the {{record_id}} variable needs to come from the CSV.

It seems that the only way I can find in any of the documentation for data file looping forces you to input this variable as a URL parameter in the style of “?parameter={{record_id}}”.

The endpoint will not accept this and needs ONLY the ID in place of the variable. None of the question mark/key/etc associated with url parameters.

I’m able to run the endpoint just fine as a one single request outside the collection runner if I manually add a single record ID to the endpoint. ex: https://myendpoint.test.com/data/a1b2c3d4/LogFile

While a collection variable seems to offer the appropriate format for the endpoint without parameters being forced, I don’t think I can use a data file for a collection variable if I’m reading everything correctly in the documentation.

Even so, I did try running it as a collection variable without success, and tried leaving the parameters in to see if the endpoint would accept - it won’t. I’m stumped.

Unless I’m using incorrect terminology for my searches, I also can’t seem to find any similar questions searching here, google, or in the documentation. There’s plenty of stuff about data file loops, but nothing about using variables without a parameter.

Anyone have any thoughts on how to achieve this, or if it is possible?

If the column header in the CSV file is called record_id, then what you had should work.

https://myendpoint.test.com/data/{{record_id}}/LogFile

This should replace {{record_id}} in the URL with the data from the CSV file on each iteration.

No need to use collection variables. Just check the console log to ensure that the URL that is being sent is as you would expect and its pulling the data from the CSV file correctly.

Hey @michaelderekjones - if I just enter {{record_id}} as a part of the endpoint of an individual request and don’t set up any type of actual variable record, it doesn’t pull anything, it puts a blank space.

https://myendpoint.test.com/data/{{record_id}}/LogFile

results in all of the loops being run as

https://myendpoint.test.com/data/ /LogFile

If I put it in as a variable at the individual request level, it forces me to add parameters as mentioned in my initial post, like so ‘?parameter={{record_id}}”’, resulting in

https://myendpoint.test.com/data/'?parameter=CorrectIdsAppearHere/LogFile

but its an uncorrected formatting

If I enter it as a collection variable

https://myendpoint.test.com/data/ /LogFile

My source file is also just a single column csv with the exact header “record_id” matching what’s inside the double curly braces I use in all the test scenarios above.

This is the main article I’ve been going off of https://blog.postman.com/looping-through-a-data-file-in-the-postman-collection-runner/?unapproved=48423&moderation-hash=13068d4210568f3bc2ad99780773c0f8#comment-48423

maybe there’s an alternate way of running data files that would work better someone knows?

If you don’t set a variable or run it though the collection runner, then it will be blank.

If the CSV file header is called “record_id”, then you just need to reference it with curly braces and on each iteration it should transpose this with the data from the CSV file.

If you are also getting a blank when setting a collection variable, then you have another issue as this should also work.

Create a collection variable called “record_id” and make sure it has the current value set.

Then use this in the URL with the curly braces. {{record_id}}

Don’t worry about the collection runner at this point. This should work on a single request.

Please note, request params and collection variables are two completely different things.

Request params will add the question marks as that is the format for request params.

Once you have the collection variable working, you should then be able to delete the variable, and use the collection runner and the CSV file in a loop.

This is an example.

Set the collection variable.

Then all you need to do in the URL is the following…

image

You can see that the record_id was sent in the request.

image