I have an API get requests in Postman that uses a data file of voucher codes to look up other information about the code, such as the name of the product the code is for. I am running this example in the dev environment. your coworkers to find and share information. A collection runner as previously introduced is used for running a whole collection together. By using our site, you acknowledge that you have read and understand our The following is a list of dynamic variables whose values are randomly generated during the request/collection run.

The example request is to the Postman Echo API, a learning resource that returns the data you send it. Set the base URL field for the API to Now select an environment from the environment selection dropdown.Once an environment is selected, Postman will replace all instances of a variable with it’s corresponding value. By clicking “Post Your Answer”, you agree to our To subscribe to this RSS feed, copy and paste this URL into your RSS reader. I have an API get requests in Postman that uses a data file of voucher codes to look up other information about the code, such as the name of the product the code is for. You body in the next request is not valid JSON and all you're going to get through for Thanks, although its now only running 1 iteration and saying there is an error, check the devtools. Note that environment variables, global variables and data variables can be used together.After clicking start, the requests are run one after the other. Using data variables you can test for hundreds of variations of a request with different IDs, tokens or content bodies.Let’s look at how you can use variables in your workflow inside Postman.For this example, let’s assume we want to create two environments, production and dev.To create the dev environment, we can just duplicate this environment so that we don’t have to type in variable keys all over again.Click the duplicate environment icon, and then click on the environment name to edit. * or pm.collectionVariables. * or pm.environment. This wouldn't set anything in those variables apart from the strings that you've added.In order to capture the response data and set it in the variable you will need to add something like this to the first requests Depending on the response schema of the first request - This should set those values as the variables. The request will be made to localhost:5000. Subsequent rows should be separated by line breaks while the values should be separated by commas. Collection Runner in Postman.

The request also uses a value variable in the body which is also pulled from the data file for each iteration. Values for these will be filled by Postman from a data file.I have also added a couple of tests which checks whether the correct value was received in the response. The Collection Runner will run the collection requests for each iteration in the data file. The JSON file is an array of objects, with each object having key/value pairs. Postman supports only simple numerical and string values inside the JSON file. It’s as easy as that!Now, let’s modify this request by adding a POST body and setting a variable inside the body.On hitting send, we see that the API received the response body with the variable replaced by it’s value.Inside Postman test scripts, you can set environment and global variables using the Data variables are used inside the Collection Runner. all i can see is thats its "undefined"Update the question with the details rather than in the comments.great i can now see that captures the variables :) but when you run the collection in collection runner im getting this in the devtools ""Cannot read property 'toString' of undefined"" could this be because im trying to loop through multiple codes from the csv file? *), then the mentioned checkbox should be Featured on Meta I hope this tutorial helped you gain a better understanding of this feature. A very common scenario while testing APIs… Continue reading "Using variables inside Postman and Collection Runner… It also executes tests and generates reports so you can see how your API tests compare to previous runs.

Stack Overflow works best with JavaScript enabled For this example, we’ll just run 2 iterations.