Bird
Raised Fist0
Postmantesting~20 mins

Response size in Postman - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Response Size Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
1:30remaining
What is the response size in bytes?
You send a GET request to an API endpoint that returns the JSON: {"name":"Alice","age":30}. Postman shows the response size as 25 bytes. What does this size represent?
AThe size of the response body in kilobytes, rounded to the nearest integer.
BThe size of the response headers only, excluding the body.
CThe size of the response body compressed with gzip.
DThe total size of the response body in bytes, including all characters in the JSON string.
Attempts:
2 left
💡 Hint

Think about what Postman counts as response size when showing it in the interface.

❓ assertion
intermediate
1:30remaining
Which assertion correctly checks response size?
You want to write a test in Postman to verify that the response size is less than 1 KB. Which assertion code snippet is correct?
Apm.test('Response size is less than 1KB', () => { pm.expect(pm.response.size()).to.be.below(1024); });
Bpm.test('Response size is less than 1KB', () => { pm.expect(pm.response.responseSize).to.be.below(1024); });
Cpm.test('Response size is less than 1KB', () => { pm.expect(pm.response.size).to.be.below(1024); });
Dpm.test('Response size is less than 1KB', () => { pm.expect(pm.response.body.size()).to.be.below(1024); });
Attempts:
2 left
💡 Hint

Check the Postman API for the correct method to get response size.

🔧 Debug
advanced
2:00remaining
Why does this Postman test fail to check response size?
Consider this Postman test code:
pm.test('Response size check', () => { const size = pm.response.responseSize; pm.expect(size).to.be.below(2048); });

Why does this test fail even when the response size is below 2048 bytes?
Postman
pm.test('Response size check', () => { const size = pm.response.responseSize; pm.expect(size).to.be.below(2048); });
AThe test fails because pm.expect requires a callback function, not a direct value.
BThe response size is measured in kilobytes, so 2048 is too small a limit.
Cpm.response.responseSize is undefined; the correct method is pm.response.size() to get the response size.
Dpm.response.responseSize returns the size of headers only, not the body.
Attempts:
2 left
💡 Hint

Check the Postman scripting API for the correct property or method to get response size.

🧠 Conceptual
advanced
1:30remaining
What does Postman include in response size measurement?
When Postman shows the response size for an API call, which parts are included in this size measurement?
AThe combined size of response headers and body in bytes.
BOnly the response body size in bytes, excluding headers and status line.
COnly the size of response headers in bytes, excluding the body.
DThe size of the response body compressed with gzip if compression is enabled.
Attempts:
2 left
💡 Hint

Observe what the 'Size' field shows in the Postman response view.

❓ framework
expert
2:00remaining
How to programmatically log response size in Postman tests?
You want to log the response size in bytes to the Postman console after each request. Which code snippet correctly does this?
Aconsole.log(`Response size: ${pm.response.size()} bytes`);
Bconsole.log('Response size: ' + pm.response.responseSize + ' bytes');
Cconsole.log(`Response size: ${pm.response.body.size} bytes`);
Dconsole.log('Response size: ' + pm.response.getSize() + ' bytes');
Attempts:
2 left
💡 Hint

Check the Postman scripting API for the method that returns response size.

Practice

(1/5)
1. What does pm.response.size().body return in Postman?
easy
A. The total number of headers in the response
B. The HTTP status code of the response
C. The size of the response body in bytes
D. The time taken to receive the response

Solution

  1. Step 1: Understand the method pm.response.size()

    This method returns an object containing sizes of different parts of the response.
  2. Step 2: Identify what .body accesses

    The .body property specifically returns the size of the response body in bytes.
  3. Final Answer:

    The size of the response body in bytes -> Option C
  4. Quick Check:

    pm.response.size().body = response body size [OK]
Hint: Remember .body gives size in bytes of response content [OK]
Common Mistakes:
  • Confusing response size with status code
  • Thinking it returns header count
  • Assuming it returns response time
2. Which of the following is the correct syntax to assert that the response body size is less than 5000 bytes in Postman test script?
easy
A. pm.response.size().body < 5000;
B. pm.expect(pm.response.size().body).to.be.below(5000);
C. assert(pm.response.body.size < 5000);
D. pm.response.size.body < 5000;

Solution

  1. Step 1: Identify correct assertion syntax in Postman

    Postman uses Chai assertion library with pm.expect() for assertions.
  2. Step 2: Check the correct property and method usage

    The correct way to get response body size is pm.response.size().body, and to assert it is below 5000 bytes, use to.be.below(5000).
  3. Final Answer:

    pm.expect(pm.response.size().body).to.be.below(5000); -> Option B
  4. Quick Check:

    Use pm.expect() with to.be.below() [OK]
Hint: Use pm.expect() with to.be.below() for size assertions [OK]
Common Mistakes:
  • Using incorrect property like pm.response.body.size
  • Missing pm.expect() wrapper
  • Using plain comparison without assertion
3. Given the following Postman test script:
<pre>pm.test('Body size check', () => { const size = pm.response.size().body; pm.expect(size).to.be.above(1000); pm.expect(size).to.be.below(3000); });
What will happen if the response body size is 3500 bytes?
medium
A. The test will fail because 3500 is not below 3000
B. The test will pass because 3500 is above 1000
C. The test will fail because 3500 is not above 1000
D. The test will pass because both conditions are true

Solution

  1. Step 1: Analyze the assertions in the test

    There are two assertions: size must be above 1000 and below 3000 bytes.
  2. Step 2: Check the given size against assertions

    3500 is above 1000 (true) but not below 3000 (false), so the second assertion fails.
  3. Final Answer:

    The test will fail because 3500 is not below 3000 -> Option A
  4. Quick Check:

    3500 < 3000? No, test fails [OK]
Hint: Check all assertions; one fail means test fails [OK]
Common Mistakes:
  • Ignoring the upper bound assertion
  • Assuming test passes if one assertion passes
  • Confusing above and below conditions
4. You wrote this Postman test:
pm.test('Check response size', () => {
  pm.expect(pm.response.size.body).to.be.below(2000);
});

But the test always fails with an error. What is the problem?
medium
A. Incorrect property access; should use pm.response.size().body
B. The assertion method to.be.below() is invalid
C. pm.expect() cannot be used inside pm.test()
D. Response size cannot be checked in Postman tests

Solution

  1. Step 1: Identify the property access error

    The code uses pm.response.size.body which is incorrect because size is a function, not an object.
  2. Step 2: Correct the syntax

    The correct syntax is pm.response.size().body to get the response body size.
  3. Final Answer:

    Incorrect property access; should use pm.response.size().body -> Option A
  4. Quick Check:

    Use parentheses for size() function [OK]
Hint: Remember size() is a function, not a property [OK]
Common Mistakes:
  • Missing parentheses after size()
  • Misusing assertion methods
  • Thinking pm.expect() is invalid inside pm.test()
5. You want to write a Postman test that fails if the response body size is either too small (less than 100 bytes) or too large (more than 5000 bytes). Which test script correctly implements this?
hard
A. pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.within(100, 5000); });
B. pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size < 100 || size > 5000).to.be.false; });
C. pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.above(100) && pm.expect(size).to.be.below(5000); });
D. pm.test('Body size limits', () => { const size = pm.response.size().body; if(size < 100 || size > 5000) { throw new Error('Body size out of limits'); } });

Solution

  1. Step 1: Understand the requirement

    The test should fail if size is less than 100 or greater than 5000 bytes.
  2. Step 2: Evaluate each option's logic

    pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.within(100, 5000); }); uses within(100, 5000) which includes 100 and 5000, but does not fail outside range explicitly.
    pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size < 100 || size > 5000).to.be.false; }); uses a boolean expression inside pm.expect() which is not a valid assertion.
    pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.above(100) && pm.expect(size).to.be.below(5000); }); uses two assertions combined with && which does not work as expected in Postman.
    pm.test('Body size limits', () => { const size = pm.response.size().body; if(size < 100 || size > 5000) { throw new Error('Body size out of limits'); } }); throws an error explicitly if size is out of limits, causing the test to fail correctly.
  3. Final Answer:

    Option D correctly fails the test when size is out of limits -> Option D
  4. Quick Check:

    Throw error to fail test on condition [OK]
Hint: Use throw Error to fail test on size limits [OK]
Common Mistakes:
  • Using invalid assertion syntax for range checks
  • Combining assertions incorrectly with &&
  • Not explicitly failing test on condition
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard