Complete the code to send a GET request in Postman.
pm.sendRequest({ url: [1], method: 'GET' }, function (err, res) { pm.expect(err).to.be.null; });The URL must be a valid API endpoint string to send a GET request.
Complete the code to check if the response status code is 200.
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
Status code 200 means the request was successful.
Fix the error in the assertion to check if the response body contains the key 'userId'.
pm.test('Response has userId', function () { pm.expect(pm.response.json()).to.have.property([1]); });
The property name must be a string, so it needs quotes around 'userId'.
Fill both blanks to extract the 'name' from the JSON response and check if it equals 'John'.
const name = pm.response.json().[1]; pm.test('Name is John', function () { pm.expect(name).[2]('John'); });
Access the 'name' property and use 'to.equal' to check exact equality.
Fill all three blanks to create a test that checks if the response time is less than 500ms and the response has a header 'Content-Type' with value 'application/json'.
pm.test('Response time and header check', function () { pm.expect(pm.response.responseTime).[1](500); pm.expect(pm.response.headers.get([2])).[3]('application/json'); });
Use 'to.be.below' to check response time less than 500ms, get the 'Content-Type' header as a string, and check it equals 'application/json'.