0
0
Postmantesting~10 mins

Rate limit testing 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 set the request method to POST in Postman test script.

Postman
pm.request.method = '[1]';
Drag options to blanks, or click blank then click option'
AGET
BPUT
CPOST
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing GET instead of POST
Using PUT or DELETE which may not be supported
2fill in blank
medium

Complete the code to check if the response status code indicates rate limiting (429).

Postman
pm.test('Status code is rate limit', () => {
  pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
A429
B403
C500
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using 403 or 500 instead of 429
Checking for 200 which means success
3fill in blank
hard

Fix the error in the test script to correctly check the 'Retry-After' header value.

Postman
pm.test('Retry-After header exists', () => {
  pm.expect(pm.response.headers.get('[1]')).to.not.be.undefined;
});
Drag options to blanks, or click blank then click option'
Aretry-after
BRetry_After
CretryAfter
DRetry-After
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or camelCase header names
Using underscores instead of hyphens
4fill in blank
hard

Fill both blanks to create a loop that sends 5 requests and checks for rate limit status.

Postman
for (let i = 0; i [1] 5; i++) {
  pm.sendRequest(pm.request.toObject(), (err, res) => {
    pm.test('Check rate limit', () => {
      pm.expect(res.status).to.equal([2]);
    });
  });
}
Drag options to blanks, or click blank then click option'
A<
B429
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= 5 causes 6 iterations
Using == or != in loop condition
5fill in blank
hard

Fill all three blanks to extract the rate limit remaining count from headers and assert it is zero.

Postman
pm.test('Rate limit remaining is zero', () => {
  const remaining = parseInt(pm.response.headers.get('[1]'));
  pm.expect(remaining).to.equal([2]);
  pm.expect(typeof remaining).to.equal('[3]');
});
Drag options to blanks, or click blank then click option'
AX-RateLimit-Remaining
B0
Cnumber
DRetry-After
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong header name
Comparing to string '0' instead of number 0
Checking type as 'string' instead of 'number'