0
0
Postmantesting~20 mins

API versioning validation in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Versioning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the test result of this Postman script validating API version header?

Given this Postman test script that checks the API version in response headers, what will be the test result?

Postman
pm.test('API version is 2.0', () => {
    pm.response.to.have.header('X-API-Version');
    pm.expect(pm.response.headers.get('X-API-Version')).to.eql('2.0');
});
ATest passes if header 'X-API-Version' exists, ignoring its value
BTest always passes regardless of header value
CTest fails with syntax error due to missing semicolon
DTest passes if header 'X-API-Version' equals '2.0', otherwise fails
Attempts:
2 left
💡 Hint

Check how the test asserts the header value exactly equals '2.0'.

assertion
intermediate
2:00remaining
Which assertion correctly verifies API version in JSON response body?

You receive this JSON response: {"version": "v1.3"}. Which Postman assertion correctly checks the version is 'v1.3'?

Apm.expect(pm.response.json().version).to.have.property('v1.3');
Bpm.expect(pm.response.json().version).to.equal('v1.3');
Cpm.expect(pm.response.json().version).to.be('v1.3');
Dpm.expect(pm.response.json().version).to.eql(1.3);
Attempts:
2 left
💡 Hint

Remember the version is a string, so the assertion must compare string values.

🔧 Debug
advanced
2:00remaining
Why does this Postman test fail when validating API version in URL path?

Test code:

pm.test('API version in URL is v2', () => {
    const url = pm.request.url.toString();
    pm.expect(url.includes('/v2/')).to.be.true;
});

But the test fails even though the URL is https://api.example.com/v2users. Why?

AThe test fails because the URL string does not contain '/v2/' exactly due to missing trailing slash
BThe test fails because pm.request.url.toString() returns an object, not a string
CThe test fails because pm.expect syntax is incorrect; should use to.equal(true)
DThe test fails because includes() is case-sensitive and URL has uppercase 'V2'
Attempts:
2 left
💡 Hint

Check the exact substring searched and the actual URL string.

framework
advanced
2:00remaining
Which Postman test script correctly validates API version in both header and JSON body?

Choose the script that checks the response header 'X-API-Version' equals '1.0' and the JSON body field 'apiVersion' equals '1.0' in one test.

A
pm.test('API version check', () => {
  pm.expect(pm.response.headers['X-API-Version']).to.equal('1.0');
  pm.expect(pm.response.json().apiVersion).to.eql('1.0');
});
B
pm.test('API version check', () => {
  pm.response.to.have.header('X-API-Version', '1.0');
  pm.expect(pm.response.json().apiVersion).to.equal(1.0);
});
C
pm.test('API version check', () => {
  pm.expect(pm.response.headers.get('X-API-Version')).to.eql('1.0');
  pm.expect(pm.response.json().apiVersion).to.eql('1.0');
});
D
pm.test('API version check', () => {
  pm.expect(pm.response.headers.get('X-API-Version')).to.equal(1.0);
  pm.expect(pm.response.json().apiVersion).to.eql('1.0');
});
Attempts:
2 left
💡 Hint

Check correct header access method and matching string types.

🧠 Conceptual
expert
2:00remaining
What is the best practice for API versioning validation in automated tests?

Which statement best describes a robust approach to validate API versioning in automated API tests?

AValidate API version in both response headers and response body to ensure consistency and detect mismatches
BValidate API version only in response headers to keep tests simple and avoid parsing response body
CValidate API version only in the URL path since headers and body can be unreliable
DSkip API version validation in tests because versioning is handled by API gateway and not relevant to functional tests
Attempts:
2 left
💡 Hint

Think about how to catch version mismatches effectively.