A few questions regarding the runner, collection variables, and data files

Hi, I am a complete noob to this stuff so I apologize ahead of time. I am using Postman version: 7.2.0

  1. Let’s say I have a collection and I have a POST and a GET. One to post a username and location, and one to get all users. I want the username to be unique.

POST payload just takes

user: “username”,
location: “location”

So, I edit collections and put in variable “username” with value user{$timestamp}.

In the body of my request, do I simply do:

username: “{username}”,
location: “location123”

It seems like it’s not working. I have tried without quotes and with quotes. Any ideas what I might be doing wrong?

  1. Let’s say I get the above to work. Now, in my GET usernames, I’d like to search for that specific user that was a dynamic value.

Would it be correct in using the “test” tab of the POST request and do something like:

pm.globals.set(“usernameToSearch”, pm.variables.get({{username}}));

Now would I be able to do the GET request and in its “test” tab put in an assertion like:

pm.test(“username is in response”, function () {
pm.expect(pm.response.text()).to.include(postman.getGlobalVariable(“usernameToSearch”));
});

  1. What happens when I start the runner and want to run this using that and a data file instead?

If I wanted to test 3 usernames, how would I do this? Everything remains the same and just create a csv to upload?

Would the CSV be:

username,location
username{$timestamp},location123
username{$timestamp},location456
username{$timestamp},location789

  1. What if I want to assert for the username and location.

Would it be:

pm.test(“username is in response”, function () {
pm.expect(pm.response.text()).to.include(data.username);
});

pm.test(“username is in response”, function () {
pm.expect(pm.response.text()).to.include(data.location));
});

  1. If that is correct, now that I leave the runner and run the steps manually, would the assertion still work? Is it looking at the data file still? Or is it now looking at the variables that I had set in the collection?

If the latter, does that mean I have to fix the assertion? I would have to keep doing this every time I switch from using runner vs manually sending a request?

Thank you for reading.

I don’t want to be rude but there is simply too much to explain as you have asked everything in one question.

It seems to me that you are missing some fundamentals in Postman - and there is nothing wrong with that. If I were you, I would invest like 2-3 hours in reading the official Postman documentation / watching some tutorials on YouTube so that you learn the basic functionality of Postman. This will most likely solve 80% of your issues as well.

Hi @Postmanoob,

Welcome to the Postman community! To help you find the answers you need, Postman has extensive documentation, you can probably start here:

If you more comfortable with video tutorials , you will find intro’s to sending requests, using variables, testing scripts and much more in the following link:

Hope that helps. Happy learning!