0
0
Postmantesting~10 mins

Status codes reading in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if the response status code is 200.

Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
A200
B404
C500
D301
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means Not Found.
Using 500 which means Server Error.
2fill in blank
medium

Complete the code to verify the response status code is in the 4xx client error range.

Postman
pm.test("Status code is client error", function () {
    pm.expect(pm.response.code).to.be.[1];
});
Drag options to blanks, or click blank then click option'
Abelow(400)
Bwithin(400, 499)
Cabove(400)
Dequal(400)
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'below(400)' which checks for codes less than 400.
Using 'equal(400)' which only checks for exactly 400.
3fill in blank
hard

Fix the error in the code to correctly assert the status code is 201.

Postman
pm.test("Status code is 201", function () {
    pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
Astatus201
B"201"
C201
Dtwo hundred one
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number making it a string.
Using descriptive text instead of the numeric code.
4fill in blank
hard

Fill both blanks to check if the status code is either 200 or 204.

Postman
pm.test("Status code is 200 or 204", function () {
    pm.expect(pm.response.code).to.be.oneOf([[1], [2]]);
});
Drag options to blanks, or click blank then click option'
A200
B201
C204
D400
Attempts:
3 left
💡 Hint
Common Mistakes
Using 201 which means Created, not requested here.
Using 400 which is a client error.
5fill in blank
hard

Fill all three blanks to assert the status code is between 200 and 299 inclusive.

Postman
pm.test("Status code is success range", function () {
    pm.expect(pm.response.code).to.be.within([1], [2]);
    pm.expect(pm.response.code).to.not.equal([3]);
});
Drag options to blanks, or click blank then click option'
A199
B200
C299
D300
Attempts:
3 left
💡 Hint
Common Mistakes
Using 199 as lower bound which is not a valid success code.
Including 300 which is outside the success range.