Bird
0
0

You want to design a REST API path to access all reviews for a specific product variant. The product ID is 20 and the variant ID is 5. Which path correctly represents this hierarchical resource?

hard📝 Application Q15 of 15
Rest API - URL and Resource Design
You want to design a REST API path to access all reviews for a specific product variant. The product ID is 20 and the variant ID is 5. Which path correctly represents this hierarchical resource?
A/products/reviews/20/variants/5
B/reviews/products/20/variants/5
C/products/20/variants/5/reviews
D/variants/5/products/20/reviews
Step-by-Step Solution
Solution:
  1. Step 1: Identify the resource hierarchy

    Reviews belong to a variant, which belongs to a product. So the path should start with product ID, then variant ID, then reviews.
  2. Step 2: Construct the path in correct order

    The correct order is /products/20/variants/5/reviews to show this nested relationship clearly.
  3. Final Answer:

    /products/20/variants/5/reviews -> Option C
  4. Quick Check:

    Parent to child order: product -> variant -> reviews [OK]
Quick Trick: Order path segments from general to specific resource [OK]
Common Mistakes:
  • Placing reviews before products or variants
  • Mixing order of product and variant IDs
  • Using unrelated resource order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes