Bird
0
0

Which URL correctly represents accessing all orders for a user with ID 42 using nested resources?

easy📝 Syntax Q3 of 15
Rest API - URL and Resource Design
Which URL correctly represents accessing all orders for a user with ID 42 using nested resources?
A/users/42/orders
B/orders/users/42
C/orders/42/users
D/users/orders/42
Step-by-Step Solution
Solution:
  1. Step 1: Identify resource hierarchy

    Orders belong to a user, so the URL should nest orders under the user resource.
  2. Step 2: Analyze URL patterns

    /users/42/orders correctly nests orders under the user with ID 42. Options B, C, and D have incorrect ordering or structure.
  3. Final Answer:

    /users/42/orders -> Option A
  4. Quick Check:

    Parent resource first, then child [OK]
Quick Trick: Parent resource ID before child resource [OK]
Common Mistakes:
  • Placing child resource before parent
  • Misordering resource segments
  • Using incorrect resource names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes