# Error when running a collection, when return code is 200?

**URL:** <https://community.postman.com/t/error-when-running-a-collection-when-return-code-is-200/41298>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [November 20, 2022, 11:33pm UTC](https://community.postman.com/t/error-when-running-a-collection-when-return-code-is-200/41298 "2022-11-20T23:33:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr\_Lister](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Mr\_Lister](https://community.postman.com/u/Mr_Lister)\
**Post date:** [November 20, 2022, 11:33pm UTC](https://community.postman.com/t/error-when-running-a-collection-when-return-code-is-200/41298/1 "2022-11-20T23:33:13Z")

</div>

Hi,

when I run a collection even though my call returns 200, the item in the collection run summary shows up as failed with a status code of 200.

Here are the results of the run

 ![postman_200_fail](https://us1.discourse-cdn.com/getpostman/original/3X/c/7/c7b24161ca7c346e7bf3fd53a2494c27d07248e0.png)

Here is my test

```auto
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);

    var json = pm.response.json();

    pm.environment.set('currentClient_Buyer', json._id);
    var currentClient_Seller = pm.environment.get("currentClient_Buyer");
    console.log('currentClient_Buyer', currentClient_Buyer);
});

```

what is interesting is when I run each of the steps from the collection one by one, they all succeed with 200! but when I run the collection, the “Buyer” call ALWAYS fails with a 200.

---

<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:** [November 21, 2022, 6:08am UTC](https://community.postman.com/t/error-when-running-a-collection-when-return-code-is-200/41298/2 "2022-11-21T06:08:39Z")

</div>

Are you sure your not getting a script error?

Is it logging out the variable you’re setting?

Could give this a go:

```auto
pm.environment.set('currentClient_Buyer', json["_id"]);

```

You’re not logging that variable correctly either as it would be `undefined`.

It’s hard to get the full context from just that static image.

---

<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:** [December 12, 2024, 12:52pm UTC](https://community.postman.com/t/error-when-running-a-collection-when-return-code-is-200/41298/3 "2024-12-12T12:52:19Z")

</div>

Closed on December 12, 2024, 12:52pm UTC

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