# Code to find disabled request header

**URL:** <https://community.postman.com/t/code-to-find-disabled-request-header/26391>\
**Category:** Help Hub\
**Created:** [August 3, 2021, 12:27pm UTC](https://community.postman.com/t/code-to-find-disabled-request-header/26391 "2021-08-03T12:27:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![indiasif](https://avatars.discourse-cdn.com/v4/letter/i/a88e57/32.png) [@indiasif](https://community.postman.com/u/indiasif)\
**Post date:** [August 3, 2021, 12:27pm UTC](https://community.postman.com/t/code-to-find-disabled-request-header/26391/1 "2021-08-03T12:27:59Z")

</div>

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

> Here’s an outline with best practices for making your inquiry.

_My question_:  
What is the code to find the disabled request header? Seems like pm.request.headers.has(‘key’, ‘value’) returns TRUE if Header/key is disabled/unselected in Postman if it has a value field has some value.

_Details (like screenshots)_:

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

_How I found the problem_:  
While validating the request headers

_I’ve already tried_:

---

<div class="post-metadata">

**Author:** ![neilstudd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/neilstudd/32/8213_2.png) [@neilstudd](https://community.postman.com/u/neilstudd)\
**Post date:** [August 3, 2021, 2:57pm UTC](https://community.postman.com/t/code-to-find-disabled-request-header/26391/2 "2021-08-03T14:57:24Z")

</div>

Hi @indiasif, welcome to the community! 👋

You are correct, by default the `pm.request.headers` list will return all of the headers, regardless of whether they were enabled. Here is such an example:

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

```auto
console.log(pm.request.headers.has("DisabledHeader")); // outputs "true"
console.log(pm.request.headers.has("EnabledHeader")); // outputs "true"

```

If you just want to get the disabled headers, you could use a `filter` command to select just the headers which are disabled, and then check to see whether your desired header exists in this new list:

```auto
var disabledHeaders = pm.request.headers.filter(header => header.disabled);
console.log(disabledHeaders.some(header => header.key == "DisabledHeader")); // outputs "true"
console.log(disabledHeaders.some(header => header.key == "EnabledHeader")); // outputs "false"

```

Hopefully this helps to solve your problem! 🙂

---

<div class="post-metadata">

**Author:** ![indiasif](https://avatars.discourse-cdn.com/v4/letter/i/a88e57/32.png) [@indiasif](https://community.postman.com/u/indiasif)\
**Post date:** [August 4, 2021, 9:23am UTC](https://community.postman.com/t/code-to-find-disabled-request-header/26391/3 "2021-08-04T09:23:02Z")

</div>

> [@neilstudd](#):
>
> `ilter` command to select just the headers which are disabled, and then check to see whether your desired header exists in this

Thanks @neilstudd. It was very useful.

---

<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:** [November 22, 2023, 10:57am UTC](https://community.postman.com/t/code-to-find-disabled-request-header/26391/4 "2023-11-22T10:57:57Z")

</div>

Closed on November 22, 2023, 10:57am UTC

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