Complete the code to set the API version header correctly in Postman.
pm.request.headers.add({ key: 'Accept-Version', value: '[1]' });The standard way to specify API version in headers is often 'v1'. This sets the 'Accept-Version' header to 'v1'.
Complete the test script to check if the API version in the response header is correct.
pm.test('API version is correct', function () { pm.expect(pm.response.headers.get('[1]')).to.eql('v1'); });
The response header 'API-Version' is commonly used to indicate the version of the API that responded.
Fix the error in the test script to correctly validate the API version in the response body JSON.
pm.test('Response has correct API version', () => { pm.expect(pm.response.json().[1]).to.equal('v1'); });
The response JSON key for API version is usually 'apiVersion' following camelCase naming.
Fill both blanks to create a test that checks the API version in both header and JSON body.
pm.test('API version consistency', () => { pm.expect(pm.response.headers.get('[1]')).to.eql('v1'); pm.expect(pm.response.json().[2]).to.eql('v1'); });
The header 'API-Version' and JSON key 'apiVersion' are standard places to check API version consistency.
Fill all three blanks to write a pre-request script that sets the API version header dynamically and a test that validates it.
pm.request.headers.upsert({ key: '[1]', value: '[2]' });
pm.test('Check version header', () => { pm.expect(pm.request.headers.get('[3]')).to.eql('v2'); });The pre-request script sets 'Accept-Version' header to 'v2'. The test checks the same header for 'v2'.