# pm.execution.skipRequest() does not work in my scripts

**URL:** <https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940>\
**Category:** Help Hub\
**Tags:** newman-project, tests\
**Created:** [February 21, 2024, 12:26pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940 "2024-02-21T12:26:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kalpanasama1](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@kalpanasama1](https://community.postman.com/u/kalpanasama1)\
**Post date:** [February 21, 2024, 12:26pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/1 "2024-02-21T12:26:03Z")

</div>

I am trying to control a request execution based on the condition I set in "pre-request script. while i run the collection manually, an error is thrown as “TypeError: Cannot read properties of undefined (reading ‘skipRequest’)”

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 21, 2024, 12:34pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/2 "2024-02-21T12:34:30Z")

</div>

This feature only works with the Collection Runner.

However it shouldn’t error like that, so can you share your code please?

---

<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:** [February 21, 2024, 2:10pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/3 "2024-02-21T14:10:48Z")

</div>

It will work at the individual level too - This one isn’t just in the Collection Runner like `sendNextRequest()`.

I think that as they have added the a Newman label is that their version of Newman isn’t up to date and that’s causing the error here.

But yeah, without more details, it’s difficult to tell either way.

---

<div class="post-metadata">

**Author:** ![kalpanasama1](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@kalpanasama1](https://community.postman.com/u/kalpanasama1)\
**Post date:** [February 22, 2024, 9:02am UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/4 "2024-02-22T09:02:34Z")

</div>

this is the code in pre-request

var utriId= pm.environment.get(“utriId1”);  
if(!utriId || utriId==null){  
pm.execution.skipRequest();  
}

the request is triggered successfully if it does not satisfy the if condition. the postman version is 10.12.13

I am running the collection in postman app itself manually from the collections run option

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 22, 2024, 11:00am UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/5 "2024-02-22T11:00:41Z")

</div>

That is working fine for me.

I’ve added a few console logs.

```auto
let utriId = pm.environment.get("utriId1");
console.log(utriId); // undefined

if (!utriId || utriId == null) {
    console.log("skip"); // skip
    pm.execution.skipRequest();

}

```

You can see from the console logs, that the IF condition is being met but no request is sent.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/7/d79965c92ce62539d38ea5aa3561e7b8b756e478.png)

How is your null variable being stored. Is it actually an boolean like your example, or perhaps its being stored as a string.

Console log the variable like I have in my example script to see what is actually being returned.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 22, 2024, 11:12am UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/6 "2024-02-22T11:12:25Z")

</div>

> [@kalpanasama1](#):
>
> the request is triggered successfully if it does not satisfy the if condition. the postman version is 10.12.13

This will be your problem. This feature was released in November 2023 (v10.20)

---

<div class="post-metadata">

**Author:** ![kalpanasama1](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@kalpanasama1](https://community.postman.com/u/kalpanasama1)\
**Post date:** [February 22, 2024, 12:15pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/7 "2024-02-22T12:15:59Z")

</div>

okay, then its the version issue

---

<div class="post-metadata">

**Author:** ![kalpanasama1](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@kalpanasama1](https://community.postman.com/u/kalpanasama1)\
**Post date:** [February 22, 2024, 1:15pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/8 "2024-02-22T13:15:03Z")

</div>

i upgraded the postman version. Now its working. But, I have a question. Will the collection with skipRequest run in newman pipeline?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 22, 2024, 1:53pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/9 "2024-02-22T13:53:01Z")

</div>

There is a pull request on Github that relates.

[Updated dependencies by KiraElric007 · Pull Request #3183 · postmanlabs/newman · GitHub](https://github.com/postmanlabs/newman/pull/3183)

I can’t actually tell if this is live. I guess I would just try it and see if it errors.

Make sure you are on an up-to-date version of node, as the pull request mentions some performance issues on previous versions.

---

<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:** [March 23, 2024, 1:53pm UTC](https://community.postman.com/t/pm-execution-skiprequest-does-not-work-in-my-scripts/57940/10 "2024-03-23T13:53:05Z")

</div>

Closed on March 23, 2024, 1:53pm UTC

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