Complete the code to set the page number in the request URL.
GET https://api.example.com/items?page=[1]The page number is set by replacing the placeholder with the actual page number, here '1'.
Complete the test script to check if the response contains the correct page number.
pm.test('Page number is correct', () => { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.eql(2); });
The response JSON usually contains a 'page' field indicating the current page number.
Fix the error in the test script to correctly check the number of items returned per page.
pm.test('Items per page count', () => { const jsonData = pm.response.json(); pm.expect(jsonData.items.length).to.eql([1]); });
The expected number of items per page is a number, so use 10 without quotes.
Fill both blanks to check if the response has the correct total pages and page size.
pm.test('Total pages and page size', () => { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.eql(5); pm.expect(jsonData.[2]).to.eql(10); });
'total_pages' gives the total number of pages, and 'page_size' gives the number of items per page.
Fill all three blanks to verify the current page, total items, and items array length.
pm.test('Verify pagination details', () => { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.eql(3); pm.expect(jsonData.[2]).to.eql(50); pm.expect(jsonData.[3].length).to.eql(10); });
'page' is the current page number, 'total_items' is the total number of items, and 'items' is the array of items returned.