# Hide empty variable in request link

**URL:** <https://community.postman.com/t/hide-empty-variable-in-request-link/37550>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [July 26, 2022, 3:14am UTC](https://community.postman.com/t/hide-empty-variable-in-request-link/37550 "2022-07-26T03:14:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickychengv](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nickychengv](https://community.postman.com/u/nickychengv)\
**Post date:** [July 26, 2022, 3:14am UTC](https://community.postman.com/t/hide-empty-variable-in-request-link/37550/1 "2022-07-26T03:14:01Z")

</div>

![Screenshot from 2022-07-26 10-56-03](https://us1.discourse-cdn.com/getpostman/original/2X/b/b65bf6675fc5948eb57d7739bf6c13caeab48e8e.png)  
 ![imageedit_1_5714006500](https://us1.discourse-cdn.com/getpostman/original/2X/a/a531f29c6799f065e1bf8e723060b703ac065c2c.png)

I have this request link with different variable. Some set of parameters will require variable “camera”, but sometime, variable “camera” is not required.  
The above example is that i dont need the variable “camera”, if the variable “camera” is removed, it will return 200.

Is it possible to remove the “camera” in request link based on some condition for example, if camera=“”, then the request link will become …/project\_id=[440]&sensor\_id=[1134,1135,1136,1137]&merge\_id=&dashboardURL=&dashboard\_title=&start=2022-07-25%2000:00:00&end=2022-07-26%2000:00:00

instead of  
…/project\_id=[440]&sensor\_id=[1134,1135,1136,1137]&merge\_id=&dashboardURL=&dashboard\_title=&start=2022-07-25%2000:00:00&end=2022-07-26%2000:00:00&camera=

thank you

---

<div class="post-metadata">

**Author:** ![nickychengv](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nickychengv](https://community.postman.com/u/nickychengv)\
**Post date:** [July 26, 2022, 5:46am UTC](https://community.postman.com/t/hide-empty-variable-in-request-link/37550/2 "2022-07-26T05:46:53Z")

</div>

i found out that pm.request.url.query.remove() can acutally do this.  
However i do not know to how to access Path Variable’s “description” in the pre-request script…  
pm.request.url.query.all() only return key-value but not “description”.

The reason i am doing this is because i want to know if the parameters is required or not

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [July 28, 2022, 12:04am UTC](https://community.postman.com/t/hide-empty-variable-in-request-link/37550/3 "2022-07-28T00:04:02Z")

</div>

> [@nickychengv](#):
>
> pm.request.url.query.all() only return key-value but not “description”.

Hi @nickychengv, Why do you need to return the description? Descriptions are blank in your screenshot.

* * *

I don’t know the exact syntax, but you could try something like this (depending on your conditional statement);

```auto
pm.request.url.query.add("camera={{camera}}")

pm.request.url.query.remove("camera={{camera}}")

```

* * *

Some more info on this thread;

> [@Modify query param in pre-request script](https://community.postman.com/t/modify-query-param-in-pre-request-script/8880/6):
>
> to add query params there is 2 ways pm.request.addQueryParams("auth\_username={{username}}") pm.request.url.query.add("auth\_password={{password}}") you can loop over pm.request.url.query it is an array of objects, every object has 3 properties { disabled: true, // only if it is disabled key: "auth\_username", value: "{{username}}", } you can find what you are looking for and set it like you wan’t

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [July 28, 2022, 12:05am UTC](https://community.postman.com/t/hide-empty-variable-in-request-link/37550/4 "2022-07-28T00:05:58Z")

</div>

Also, be aware of this…

![image](https://us1.discourse-cdn.com/getpostman/original/2X/9/97e317c96c12541f7272d9ed7f3491dfa74a62f6.png)

Thus, you can’t access it as part of the request/response.
