Complete the code to set the correct Content-Type header for JSON body in Postman.
pm.request.headers.add({ key: 'Content-Type', value: '[1]' });The Content-Type header must be 'application/json' to match the JSON body format expected by the API.
Complete the code to parse the JSON response body in Postman test script.
const responseData = pm.response.json();
const userId = responseData.[1];The 'id' field typically holds the user identifier in the JSON response, matching API expectations.
Fix the error in the test script to correctly check if the response body matches expected JSON format.
pm.test('Response has valid JSON', function () { pm.expect(pm.response.[1]()).to.be.an('object'); });
Using pm.response.json() parses the response body as JSON, allowing the test to check its structure.
Fill both blanks to correctly set a JSON body and send the request in Postman pre-request script.
pm.request.body.raw = JSON.stringify({ [1]: 'John', [2]: 30 });The JSON body keys must match the API's expected fields, here 'name' and 'age'.
Fill all three blanks to write a test that asserts the response JSON has a 'success' field true and a 'data' object.
pm.test('Response success and data check', function () { const jsonData = pm.response.[1](); pm.expect(jsonData.[2]).to.eql(true); pm.expect(jsonData.[3]).to.be.an('object'); });
The test parses JSON, checks that 'success' is true, and that 'data' is an object, matching API response expectations.