# Assignment #2 gives error even though I have pm.response.code

**URL:** <https://community.postman.com/t/assignment-2-gives-error-even-though-i-have-pm-response-code/67466>\
**Category:** Help Hub\
**Tags:** tests, collections\
**Created:** [August 26, 2024, 9:32pm UTC](https://community.postman.com/t/assignment-2-gives-error-even-though-i-have-pm-response-code/67466 "2024-08-26T21:32:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortypython1](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mortypython1](https://community.postman.com/u/mortypython1)\
**Post date:** [August 26, 2024, 9:32pm UTC](https://community.postman.com/t/assignment-2-gives-error-even-though-i-have-pm-response-code/67466/1 "2024-08-26T21:32:50Z")

</div>

Hi,  
I am doing the Postman API Test Automation for Beginners by freecodecamp by [‪@vdespa‬](https://www.youtube.com/@vdespa) and facing issue on the asignment #2

The ‘Verify your work’ send reques gives pass to all expect on as follows:  
orders \> Create a new order: contains status code test | AssertionError: check script: expected ‘pm.test(“Status code is 200”, functio…’ to include ‘pm.expect(pm.response.code).to.eql(20…’

However in my orders \> Create a new order i have the following codes:  
pm.test(“Status code is 200”, function () {  
pm.response.to.have.status(200);  
pm.expect(pm.response.code).to.eql(200);  
});

I also tried the following but got the same message:  
pm.test(“Status code is 200”, function () {  
pm.expect(pm.response.code).to.eql(200);  
});

I would appreciate it if anyone can help.

---

<div class="post-metadata">

**Author:** ![mortypython1](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mortypython1](https://community.postman.com/u/mortypython1)\
**Post date:** [September 4, 2024, 6:35am UTC](https://community.postman.com/t/assignment-2-gives-error-even-though-i-have-pm-response-code/67466/2 "2024-09-04T06:35:15Z")

</div>

it was the code that was the issue so it should have been:  
pm.test(“Status code is 200 or 201”, function() {  
pm.expect(pm.response.code).to.be.oneOf([200, 201]);  
});

---

<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:** [October 4, 2024, 6:35am UTC](https://community.postman.com/t/assignment-2-gives-error-even-though-i-have-pm-response-code/67466/3 "2024-10-04T06:35:21Z")

</div>

Closed on October 4, 2024, 6:35am UTC

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