Friday, August 12, 2016

API Automation with postman : Pass Data file in runner


 We go through the collection feature of postman.

Lets start basic usage of collection in runner. To run a collection, open the Collection Runner window by clicking on the link in the navigation bar. Choose a collection from the drop down menu, and hit Start.



So this way you can iterate your collection as many time as you want. So your collection run multiple time as you set value in iteration field.

Second thing is you can run your collection by giving csv or json file to pass your data in your API collection. The Collection Runner let’s you import a CSV or a JSON file and then use the values from the data file inside HTTP requests and scripts. We call these variables data variables. To use them inside the Postman UI, you have to follow the same syntax as environment or global variables. Having the same syntax helps you test individual requests inside Postman using dummy environment values. When you move to the Collection Runner you don’t have to change anything.

Data variables in requests
Variables inside the Postman UI are enclosed inside curly braces. For example, in the screenshot below, {{username}} and {{password}} inside URL parameters would be replaced by corresponding values from the data file:


So like this way you can also pass data to the API and run your collection with different data value.


CSV files
For CSV files to work inside the Collection Runner, the first row needs to consist of variable names that you want to use inside requests. Every subsequent row is used as a data row. Make sure the line endings of the CSV file are in the Unix format. That’s a restriction in our current CSV parser.





JSON files
The JSON file needs to be an array of key/value pairs. The keys are used as variable names while the values are replaced inside requests.







For more information you can check  Using CSV data file post in postman blog.






No comments:

Post a Comment