Bird
0
0

You want to support two API versions (v1 and v2) simultaneously using header-based versioning. Which approach correctly handles this in your server code?

hard📝 Application Q15 of 15
Rest API - Versioning Strategies
You want to support two API versions (v1 and v2) simultaneously using header-based versioning. Which approach correctly handles this in your server code?
ACheck the Accept header for 'application/vnd.example.v1+json' or 'application/vnd.example.v2+json' and route accordingly
BUse URL paths like /v1/resource and /v2/resource to separate versions
CIgnore headers and always serve the latest version
DUse query parameters like ?version=1 or ?version=2 to select version
Step-by-Step Solution
Solution:
  1. Step 1: Understand header-based versioning goal

    It requires checking the HTTP headers to determine which API version to serve.
  2. Step 2: Identify correct version detection method

    Checking the Accept header for specific version strings and routing requests accordingly is the right approach.
  3. Final Answer:

    Check the Accept header for 'application/vnd.example.v1+json' or 'application/vnd.example.v2+json' and route accordingly -> Option A
  4. Quick Check:

    Route by Accept header version strings [OK]
Quick Trick: Route requests by Accept header version values [OK]
Common Mistakes:
  • Mixing header versioning with URL or query parameter versioning
  • Ignoring version headers and serving one version only
  • Using wrong headers for version detection

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes