0
0
Postmantesting~10 mins

Flow creation 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 POST in a Postman test script.

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

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

Postman
pm.request.body.raw = JSON.stringify([1]);
Drag options to blanks, or click blank then click option'
A'{"key":"value"}'
B{ key: 'value' }
C{ "key": "value" }
D'data: 123'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string instead of object before JSON.stringify.
Incorrect quotes around keys or values.
3fill in blank
hard

Fix the error in the code to correctly set a header in a Postman test script.

Postman
pm.request.headers.add({ key: '[1]', value: 'application/json' });
Drag options to blanks, or click blank then click option'
AContent-Type
Bcontenttype
CContentType
Dcontent-type
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect header key spelling.
Omitting the hyphen in Content-Type.
4fill in blank
hard

Fill both blanks to create a test that checks if the response status code is 200 in Postman.

Postman
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); pm.expect(pm.response.code).to.be.[2](200); });
Drag options to blanks, or click blank then click option'
A200
Bequal(200)
Cequal
Dstatus(200)
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertion methods incorrectly.
Putting the assertion method in the first blank.
5fill in blank
hard

Fill all three blanks to create a test that verifies the response JSON has a key 'success' with value true in Postman.

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