0
0
Postmantesting~10 mins

API versioning validation 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 API version header correctly in Postman.

Postman
pm.request.headers.add({ key: 'Accept-Version', value: '[1]' });
Drag options to blanks, or click blank then click option'
Av1
Bver1
Capi_v1
Dversion1
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-standard version strings like 'version1' or 'api_v1' which may not be recognized by the API.
2fill in blank
medium

Complete the test script to check if the API version in the response header is correct.

Postman
pm.test('API version is correct', function () { pm.expect(pm.response.headers.get('[1]')).to.eql('v1'); });
Drag options to blanks, or click blank then click option'
AVersion
BContent-Type
CAccept-Version
DAPI-Version
Attempts:
3 left
💡 Hint
Common Mistakes
Checking wrong headers like 'Content-Type' or 'Accept-Version' which are not response version headers.
3fill in blank
hard

Fix the error in the test script to correctly validate the API version in the response body JSON.

Postman
pm.test('Response has correct API version', () => { pm.expect(pm.response.json().[1]).to.equal('v1'); });
Drag options to blanks, or click blank then click option'
Aversion
BapiVersion
Capi_ver
Dversion_api
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect key names like 'version_api' or 'api_ver' that do not exist in the response.
4fill in blank
hard

Fill both blanks to create a test that checks the API version in both header and JSON body.

Postman
pm.test('API version consistency', () => { pm.expect(pm.response.headers.get('[1]')).to.eql('v1'); pm.expect(pm.response.json().[2]).to.eql('v1'); });
Drag options to blanks, or click blank then click option'
AAPI-Version
BapiVersion
CAccept-Version
Dversion
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing header and JSON key names or using incorrect keys.
5fill in blank
hard

Fill all three blanks to write a pre-request script that sets the API version header dynamically and a test that validates it.

Postman
pm.request.headers.upsert({ key: '[1]', value: '[2]' });
pm.test('Check version header', () => { pm.expect(pm.request.headers.get('[3]')).to.eql('v2'); });
Drag options to blanks, or click blank then click option'
AAccept-Version
Bv2
CAPI-Version
DVersion
Attempts:
3 left
💡 Hint
Common Mistakes
Using different header keys in setting and checking causing test failures.