Complete the code to set the request method to POST in Postman test script.
pm.request.method = '[1]';
Setting the method to POST is required to test rate limits on POST endpoints.
Complete the code to check if the response status code indicates rate limiting (429).
pm.test('Status code is rate limit', () => { pm.response.to.have.status([1]); });
Status code 429 means Too Many Requests, which is used for rate limiting.
Fix the error in the test script to correctly check the 'Retry-After' header value.
pm.test('Retry-After header exists', () => { pm.expect(pm.response.headers.get('[1]')).to.not.be.undefined; });
HTTP headers are case-insensitive but Postman expects the exact header name as sent, usually Retry-After.
Fill both blanks to create a loop that sends 5 requests and checks for rate limit status.
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]); }); }); }
The loop should run while i < 5 to send 5 requests (0 to 4). The status to check is 429 for rate limiting.
Fill all three blanks to extract the rate limit remaining count from headers and assert it is zero.
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]'); });
The header X-RateLimit-Remaining shows how many requests remain. It should be zero after hitting the limit. The type of remaining is number after parsing.