0
0
Postmantesting~10 mins

DELETE request in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the HTTP method to DELETE in Postman.

Postman
pm.request.method = '[1]';
Drag options to blanks, or click blank then click option'
ADELETE
BGET
CPOST
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET or POST instead of DELETE.
Misspelling the method name.
2fill in blank
medium

Complete the code to check if the DELETE request returned status code 204.

Postman
pm.test('Status code is 204', () => { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A200
B500
C204
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for 200 instead of 204.
Using a client or server error code.
3fill in blank
hard

Fix the error in the test script to correctly verify the DELETE response body is empty.

Postman
pm.test('Response body is empty', () => { pm.expect(pm.response.text()).to.[1](''); });
Drag options to blanks, or click blank then click option'
Acontain
Bequal
Cinclude
Dhave
Attempts:
3 left
💡 Hint
Common Mistakes
Using contain or include which check partial matches.
Using have which is not a valid Chai assertion method here.
4fill in blank
hard

Fill both blanks to set a DELETE request header and verify it in the test script.

Postman
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'); });
Drag options to blanks, or click blank then click option'
AContent-Type
BAuthorization
CAccept
DUser-Agent
Attempts:
3 left
💡 Hint
Common Mistakes
Using different header names in add and get.
Using headers unrelated to content type.
5fill in blank
hard

Fill all three blanks to create a test that verifies the DELETE request URL and method.

Postman
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');
});
Drag options to blanks, or click blank then click option'
Ahttps://api.example.com/items/123
BDELETE
C1
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of DELETE for method.
Incorrect URL or path index.