Loop for GET with different parameters from the file

Hi,

There is Request GET for WEB service with List of parameters in the body

Question: How to create loop with different Requests from file, contains several sets of Parameters list? (see shapshot)

Hey @VadiksC :wave:

Welcome to the Postman Community! :postman:

You can iterate over a JSON or CSV data file using the Collection Runner.

This will then allow you to replace those hardcoded values in the request, with variables using the {{variable_name}} syntax.

We have a Level Up Video of this behaviour that will show you how this can be done. Some parts of the UI might be slightly different but this should still walkthrough the main parts.

Thanks for answer

If I send “data bulk” with more comprehensive structure (not Key + Value like in the video) in format of RAW data:

WS1,0437239C8AE5
223090100,ptD_Trim_Code_Recommendation,Main.HS_REFGENTRIM_TUR.HS_REFGEN_PHY_NORTH_ATB_VBG_TRIM_TUR,
223090150,ptD_Vbg_at_Coarse_Trim_Start,Main.HS_REFGENTRIM_TUR.HS_REFGEN_PHY_NORTH_ATB_VBG_TRIM_TUR,

The following is a sample HTTP GET required: (from example above in specified linefeed format)
WS1 ---------> KEY
0437239C8AE5 ---------> {{variable_name}}

223090100 ---------> {{variable_name}}
ptD_Trim_Code_Recommendation ---------> {{variable_name}}
Main.HS_REFGENTRIM_TUR.HS_REFGEN_PHY_NORTH_ATB_VBG_TRIM_TUR ---------> {{variable_name}}

Here is Response: (for 2 lines of data)

Question: Is it possible to implement reading these parameters from a .csv or other file?

You can still use variables in a raw text body

For example…

WS1,{{data.variableName}}

You just need to ensure that your CSV file has a column header for each variable you want. So it may need a bit of work in formatting.

You use the special “data” element to to define the variable for the current iteration. So it would be data.columnheader (with the column header being the name of the variable).

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