Complete the code to set the HTTP method to GET in Postman.
pm.request.method = '[1]';
The HTTP method GET is used to request data from a server. Setting pm.request.method = 'GET' correctly configures the request.
Complete the code to check if the response status code is 200 in Postman test script.
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
The status code 200 means the request was successful. The test checks if the response status matches 200.
Fix the error in the code to correctly check if the response body contains the string 'success'.
pm.test('Body contains success', function () { pm.expect(pm.response.text()).to.[1]('success'); });
toBe or toEqual which require exact matches.toHaveLength which checks length, not content.The contain assertion checks if the response text includes the substring 'success'. Other options do not check substring presence.
Fill both blanks to parse JSON response and check if the 'status' field equals 'ok'.
let jsonData = pm.response.[1](); pm.test('Status is ok', function () { pm.expect(jsonData.[2]).to.eql('ok'); });
pm.response.text() which returns raw string, not parsed JSON.Use pm.response.json() to parse JSON response. Then access the status field to check its value.
Fill all three blanks to write a test that checks if the response JSON has a 'data' array with length greater than 0.
let jsonData = pm.response.[1](); pm.test('Data array is not empty', function () { pm.expect(jsonData.[2].[3]).to.be.above(0); });
pm.response.text() instead of json().Parse the response JSON with pm.response.json(). Access the data array and check its length property to ensure it has items.