Complete the code to set the HTTP method to DELETE in Postman.
pm.request.method = '[1]';
The HTTP method must be set to DELETE to perform a delete request.
Complete the code to check if the DELETE request returned status code 204.
pm.test('Status code is 204', () => { pm.response.to.have.status([1]); });
Status code 204 means the DELETE request was successful and no content is returned.
Fix the error in the test script to correctly verify the DELETE response body is empty.
pm.test('Response body is empty', () => { pm.expect(pm.response.text()).to.[1](''); });
Use equal to check that the response text is exactly an empty string.
Fill both blanks to set a DELETE request header and verify it in the test script.
pm.request.headers.add({ key: '[1]', value: 'application/json' });
pm.test('Header is set', () => { pm.expect(pm.request.headers.get('[2]')).to.equal('application/json'); });The Content-Type header specifies the media type of the request body. Both adding and checking must use the same header name.
Fill all three blanks to create a test that verifies the DELETE request URL and method.
pm.test('Request URL and method are correct', () => { pm.expect(pm.request.url.toString()).to.equal('[1]'); pm.expect(pm.request.method).to.equal('[2]'); pm.expect(pm.request.url.path[[3]]).to.equal('123'); });
The test checks that the full URL matches the expected string, the method is DELETE, and the last segment of the URL path (index 1) is '123'.