# Query Parameter can be access through .csv file?

**URL:** <https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497>\
**Category:** Help Hub\
**Created:** [December 15, 2020, 6:31pm UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497 "2020-12-15T18:31:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [December 15, 2020, 6:31pm UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497/1 "2020-12-15T18:31:20Z")

</div>

Hi Team,

I have one scenario whereas need to change query parameter values based on the related scenario.  
If I can create one individual scenario then might be 50 sets of request needs to be create based on the different query parameter.

Can we do with .csv file where we can store different sets of query parameter at each row and iteration can follow up.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/f/c/fcce4c360130d89248ee41ad0fbbc234750ec95c.png)  
If you see in the above image, I need to change values based on the requirement.  
Let me know if needed any other info.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [December 16, 2020, 5:12am UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497/2 "2020-12-16T05:12:10Z")

</div>

Hi @aakashjain8693,

Due to some constraints, I couldn’t work on .csv files. So you please try the below with the .csv file.

So you are saying that for every iteration you have the different set of query parameters ready with you?

If that’s case, have your .CSV files ready and the process is similar to usual data driven approach.

For example:

Under Pre-request script, add the desired fields you need:

```auto
pm.environment.set("pageNumber", data.pageNumber);
pm.environment.set("pageSize", data.pageSize);

```

so on…

then the process is same, the csv file name is as “data.csv”

and select the file it automatically loads with number of iterations.

---

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [December 16, 2020, 7:47am UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497/3 "2020-12-16T07:47:03Z")

</div>

Perfect, What I was doing mistake, Trying to put same stuff in test section instead of pre-request script section.

Test section something like I was trying  
variable name= data.pageNumber;

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [December 16, 2020, 8:07am UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497/4 "2020-12-16T08:07:17Z")

</div>

If you have that data in a CSV file and the variable names are unique and not used in any other scope - you should just be able to use the `{{var_name}}` syntax in the params without the need to add anything to the scripts.

---

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [December 16, 2020, 10:03am UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497/5 "2020-12-16T10:03:51Z")

</div>

Thanks @danny-dainton, Worked for me.  
Before the scripting, I was doing exactly the same but variable names were duplicate.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [December 16, 2020, 10:09am UTC](https://community.postman.com/t/query-parameter-can-be-access-through-csv-file/18497/6 "2020-12-16T10:09:32Z")

</div>

Having the same name is fine but you just need to think about the scope of the variables and understand why one might be chosen over another one.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/0/10344f7211bcd6705248e93d9a1fc755f9c71777.png)

> **[Using variables | Postman Learning Center](https://learning.postman.com/docs/sending-requests/variables/#variable-scopes)**
>
> Using variables: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.
