0
0
Postmantesting~10 mins

PATCH 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 PATCH in Postman.

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

Complete the code to add a JSON body with a field 'status' set to 'active' for the PATCH request.

Postman
pm.request.body.raw = JSON.stringify({"status": [1] });
Drag options to blanks, or click blank then click option'
A'active'
B"active"
C'inactive'
D"inactive"
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes inside JSON string which is invalid
Not stringifying the object
3fill in blank
hard

Fix the error in the test script to check if the PATCH response status code is 200.

Postman
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A"200"
BstatusCode
C'200'
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 200 making it a string
Using undefined variables like statusCode
4fill in blank
hard

Fill both blanks to set the Content-Type header to application/json for the PATCH request.

Postman
pm.request.headers.add({ key: [1], value: [2] });
Drag options to blanks, or click blank then click option'
A"Content-Type"
B"application/json"
C"Accept"
D"text/plain"
Attempts:
3 left
💡 Hint
Common Mistakes
Using Accept header instead of Content-Type
Setting wrong content type like text/plain
5fill in blank
hard

Fill all three blanks to write a test that checks the PATCH response JSON has a 'status' field equal to 'active'.

Postman
pm.test('Response status is active', function () { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.eql([2]); pm.expect(pm.response.code).to.equal([3]); });
Drag options to blanks, or click blank then click option'
Astatus
B"active"
C200
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Checking wrong JSON field
Using single quotes instead of double quotes for JSON string
Checking wrong status code