0
0
Postmantesting~10 mins

Response body inspection 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 body contains the expected status.

Postman
pm.test("Status is OK", function () {
    pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
A301
B404
C200
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status code like 404 or 500.
Forgetting to use pm.response.to.have.status.
2fill in blank
medium

Complete the code to parse the JSON response body.

Postman
let jsonData = pm.response.json();
pm.test("Check user name", function () {
    pm.expect(jsonData.name).to.eql([1]);
});
Drag options to blanks, or click blank then click option'
AJohn
B"John"
C'John'
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the string value.
Using single quotes which may cause syntax issues in JSON context.
3fill in blank
hard

Fix the error in the assertion to check if the response body has a property 'success' set to true.

Postman
pm.test("Success is true", function () {
    pm.expect(pm.response.json().success).to.be.[1];
});
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cok
Dexist
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exist' which checks if the property exists but not its value.
Using 'ok' which is not a valid assertion here.
4fill in blank
hard

Fill both blanks to check if the response JSON has a property 'data' and that it is an array.

Postman
pm.test("Data is an array", function () {
    let jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property([1]);
    pm.expect(Array.isArray(jsonData.[2])).to.be.true;
});
Drag options to blanks, or click blank then click option'
A"data"
Bdata
C"items"
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted property name in have.property() causing syntax error.
Using wrong property name like 'items' instead of 'data'.
5fill in blank
hard

Fill all three blanks to test that the response JSON has a 'user' object with a 'role' property equal to 'admin'.

Postman
pm.test("User role is admin", function () {
    let jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property([1]);
    pm.expect(jsonData.[2]).to.have.property([3]);
    pm.expect(jsonData.user.role).to.eql("admin");
});
Drag options to blanks, or click blank then click option'
A"user"
Buser
C"role"
Drole
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting property names in have.property() causing errors.
Mixing up quotes and variable names.