0
0
Postmantesting~10 mins

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

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

Complete the code to add a JSON body to the PUT request in Postman.

Postman
pm.request.body.raw = JSON.stringify({"name": "John", "age": 30});
pm.request.body.mode = '[1]';
Drag options to blanks, or click blank then click option'
Araw
Bformdata
Curlencoded
Dfile
Attempts:
3 left
💡 Hint
Common Mistakes
Setting mode to formdata or urlencoded when sending raw JSON
Not setting the body mode at all
3fill in blank
hard

Fix the error in the code to set the Content-Type header for a PUT request in Postman.

Postman
pm.request.headers.upsert('Content-Type', '[1]');
Drag options to blanks, or click blank then click option'
Aapplication/xml
Bapplication/json
Ctext/plain
Dmultipart/form-data
Attempts:
3 left
💡 Hint
Common Mistakes
Using text/plain or application/xml for JSON data
Forgetting to set the Content-Type header
4fill in blank
hard

Fill both blanks to correctly check the PUT response status and parse JSON in Postman test script.

Postman
pm.test('Status code is [1]', () => {
    pm.response.to.have.status([2]);
});
Drag options to blanks, or click blank then click option'
A'200 OK'
B200
C'404 Not Found'
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers in the test description string
Using strings instead of numbers in status check
5fill in blank
hard

Fill all three blanks to write a test that checks the PUT response JSON has a 'success' key set to true.

Postman
pm.test('Response has success true', () => {
    const jsonData = pm.response.json();
    pm.expect(jsonData.[1]).to.eql([2]);
    pm.expect(typeof jsonData.[3]).to.eql('boolean');
});
Drag options to blanks, or click blank then click option'
Asuccess
Btrue
CsuccessFlag
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'successFlag' instead of 'success'
Using string 'true' instead of boolean true