Bird
0
0

You are designing a REST API to retrieve all reviews for a product with ID 321. Which is the best noun-based resource path?

hard📝 Application Q8 of 15
Rest API - URL and Resource Design
You are designing a REST API to retrieve all reviews for a product with ID 321. Which is the best noun-based resource path?
A/productReviews/321
B/reviews?productId=321
C/getProductReviews/321
D/products/321/reviews
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested resource naming

    Nested resources use the parent resource followed by child resource.
  2. Step 2: Evaluate options

    /products/321/reviews correctly nests 'reviews' under 'products/321'. /reviews?productId=321 uses query parameters, /getProductReviews/321 uses verbs, /productReviews/321 combines nouns awkwardly.
  3. Final Answer:

    /products/321/reviews -> Option D
  4. Quick Check:

    Use nested nouns for related resources [OK]
Quick Trick: Nest child resource under parent resource path [OK]
Common Mistakes:
  • Using verbs in resource paths
  • Using query parameters instead of nested paths
  • Combining nouns improperly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes