Complete the code to set the HTTP method to POST in Postman.
pm.request.method = '[1]';
The HTTP method must be set to POST to send data to the server.
Complete the code to add a JSON body to the POST request in Postman.
pm.request.body.raw = JSON.stringify([1]);The body must be a valid JSON string. Using JSON.stringify on a JSON object literal is correct.
Fix the error in setting the Content-Type header for a JSON POST request.
pm.request.headers.add({key: 'Content-Type', value: '[1]'});The Content-Type header must be application/json to indicate JSON data is sent.
Fill both blanks to correctly check the POST response status and parse JSON body in Postman test script.
pm.test('Status code is [1]', () => { pm.response.to.have.status([2]); });
For a successful POST, status code 201 (Created) is expected. The test checks if response has status 201.
Fill all three blanks to extract a field from JSON response and assert its value in Postman test script.
const responseData = pm.response.[1](); pm.test('Check user name', () => { pm.expect(responseData.[2]).to.eql('[3]'); });
Use pm.response.json() to parse JSON response. Then check the name field equals 'John'.