# Test Passes in Postman (200 Ok) but fails in Newman (404 Not Found)

**URL:** <https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610>\
**Category:** Help Hub\
**Tags:** newman-project, setenvironmentvariab, environment\
**Created:** [June 23, 2020, 1:03pm UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610 "2020-06-23T13:03:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fairouz05](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@fairouz05](https://community.postman.com/u/fairouz05)\
**Post date:** [June 23, 2020, 1:03pm UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/1 "2020-06-23T13:03:08Z")

</div>

Hi, I am writing a test script where I am using an environment variable, setting it to a constant value in pre-request script and finally, assigning it to my request body parameter.

Pre-request Script -  
`var code = "b0d159"; pm.environment.set("offeringCode", code)`

Request Body -  
`{ "Service": "OfferingService", "Action": "createOffering", "Params": { "OfferingCode": "{{offeringCode}}", "Name": "{{offeringName}}", "Description" : null, "OrganizationID" : null} `

Test Script (test that is failing) -  
`pm.test('response code is 200', function () { pm.response.to.be.ok; });`

I am setting an already existing value (exists in db) to the variable, thus the request should return “Overlapping offering code” in response body.  
While running the request/ collection from postman expected response comes with a 200 Ok status, however, Newman returns “Missing Parameter” with a 404 Not Found status.  
In Newman, the “detail” column for assertion error says - " response code is 200  
expected response to have status reason ‘OK’ but got ‘NOT FOUND’ at assertion:0 in test-script inside “Overlapping Offering Code”

What could be the reason behind this?

---

<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:** [June 23, 2020, 1:38pm UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/2 "2020-06-23T13:38:17Z")

</div>

Hey @fairouz05

Welcome to the community! 👋

What is the command that you’re using to run the Collection in Newman?

Are you specifying an environment file in the run?

---

<div class="post-metadata">

**Author:** ![fairouz05](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@fairouz05](https://community.postman.com/u/fairouz05)\
**Post date:** [June 23, 2020, 1:44pm UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/3 "2020-06-23T13:44:55Z")

</div>

Yes, here is the command (after I give path to the folder where I have saved the collection.json and environment.json file )

newman run “Create Offering.postman\_collection.json” -e “API Demo Env Copy.postman\_environment.json” --reporters cli,html --insecure

---

<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:** [June 23, 2020, 6:41pm UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/4 "2020-06-23T18:41:19Z")

</div>

That’s seems odd, are you saving the request your editing before exporting the file to use with Newman?

I’ve got to say it breaks my little heart that you’re not using `htmlextra` but not everyone has discovered it yet 😁

---

<div class="post-metadata">

**Author:** ![fairouz05](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@fairouz05](https://community.postman.com/u/fairouz05)\
**Post date:** [June 24, 2020, 11:22am UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/5 "2020-06-24T11:22:40Z")

</div>

Hey there, I found what went wrong using htmlextra! One of the environment variables was in wrong format which was causing the “Missing Parameter” response, I included the right code in pre-request script and now it works! Thank you 🙂

---

<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:** [June 24, 2020, 11:27am UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/6 "2020-06-24T11:27:40Z")

</div>

That’s awesome!! So glad it lead you to the right place!!

Thanks for using the reporter 🏆

---

<div class="post-metadata">

**Author:** ![emmanueladedeji](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@emmanueladedeji](https://community.postman.com/u/emmanueladedeji)\
**Post date:** [November 15, 2022, 10:32pm UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/7 "2022-11-15T22:32:14Z")

</div>

This was helpful for me as well htmlextra reports are quite detail. Thanks for this

---

<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:** [August 23, 2023, 11:20am UTC](https://community.postman.com/t/test-passes-in-postman-200-ok-but-fails-in-newman-404-not-found/13610/8 "2023-08-23T11:20:33Z")

</div>

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