# Use variable in request URL?

**URL:** <https://community.postman.com/t/use-variable-in-request-url/59553>\
**Category:** Help Hub\
**Tags:** variables, url-params\
**Created:** [April 3, 2024, 6:12pm UTC](https://community.postman.com/t/use-variable-in-request-url/59553 "2024-04-03T18:12:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewism1992](https://avatars.discourse-cdn.com/v4/letter/l/7bcc69/32.png) [@lewism1992](https://community.postman.com/u/lewism1992)\
**Post date:** [April 3, 2024, 6:12pm UTC](https://community.postman.com/t/use-variable-in-request-url/59553/1 "2024-04-03T18:12:53Z")

</div>

My request URL is:  
[https://api.limblecmms.com:443/v2/assets/{{assetID}](https://api.limblecmms.com:443/v2/assets/%7B%7BassetID%7D)}/fields

I created ‘assetID’ as a variable in the URL. How can I use the Pre-Request Script to make this iterate thru a list of integers as variable ‘assetID’?

For example… I want assetID = 10, 11, 12, 13, 14, 15.

---

<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:** [April 4, 2024, 10:20am UTC](https://community.postman.com/t/use-variable-in-request-url/59553/2 "2024-04-04T10:20:59Z")

</div>

Hey @lewism1992 👋

Welcome to the Postman Community! :postman:

What have you tried so far? Are you looking to use a datefile with the Runner or are you trying to achieve this in a different way?

---

<div class="post-metadata">

**Author:** ![lewism1992](https://avatars.discourse-cdn.com/v4/letter/l/7bcc69/32.png) [@lewism1992](https://community.postman.com/u/lewism1992)\
**Post date:** [April 4, 2024, 1:05pm UTC](https://community.postman.com/t/use-variable-in-request-url/59553/3 "2024-04-04T13:05:06Z")

</div>

Hello Danny,

Honestly, I’m not quite sure. Postman was brand new to me only a few days ago, so I am unfamiliar with a Runner and datefile. What do you recommend?

I was hoping that I could write a simple For loop to iterate thru integers…

---

<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:** [April 4, 2024, 1:15pm UTC](https://community.postman.com/t/use-variable-in-request-url/59553/4 "2024-04-04T13:15:18Z")

</div>

There are a number of ways that it could be done, both with and without the Runner.

Using a datafile (Either a JSON or CSV) which holds the values you would like to iterate over would be easier without needing to create any scripts.

The _column name_ in the CSV or the _object key_ in the JSON file will be the same name as your `{{assetID}}` placeholder variable. Each iteration would use a new value in the request URL and replace the variable.

I’ve attached the doc from the learning center but i’m happy to go through any follow up questions you may have:

> **[Run collections using imported data | Postman Learning Center](https://learning.postman.com/docs/collections/running-collections/working-with-data-files/)**
>
> Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [May 4, 2024, 1:15pm UTC](https://community.postman.com/t/use-variable-in-request-url/59553/5 "2024-05-04T13:15:48Z")

</div>

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