Bird
0
0

You want to list all reviews for a product and also filter reviews by rating using nested resources. Which URL and query parameter combination is correct?

hard📝 Application Q8 of 15
Rest API - URL and Resource Design
You want to list all reviews for a product and also filter reviews by rating using nested resources. Which URL and query parameter combination is correct?
A/products/12/reviews?rating=5
B/reviews/12/products?rating=5
C/products/reviews/12?rating=5
D/products/12?reviews=5
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct nested URL for reviews under product

    The URL should nest reviews under the product ID: /products/12/reviews.
  2. Step 2: Use query parameter for filtering

    Filtering by rating is done with a query parameter like ?rating=5 appended to the URL.
  3. Final Answer:

    /products/12/reviews?rating=5 -> Option A
  4. Quick Check:

    Nested resource + query filter = correct URL [OK]
Quick Trick: Use query parameters to filter nested resource lists [OK]
Common Mistakes:
  • Placing resources in wrong order
  • Using query parameters incorrectly
  • Confusing resource IDs with filter values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes