Bird
0
0

Which of the following is the correct way to structure a REST API URL for accessing a user's orders?

easy📝 Syntax Q12 of 15
Rest API - URL and Resource Design
Which of the following is the correct way to structure a REST API URL for accessing a user's orders?
A/user/123/orders
B/orders/user/123
C/123/orders/user
D/orders/123user
Step-by-Step Solution
Solution:
  1. Step 1: Identify the resource hierarchy

    The URL should start with the main resource (user), then the specific user ID, then the sub-resource (orders).
  2. Step 2: Check each option

    /user/123/orders follows the pattern /user/{id}/orders, which is clear and standard. Others mix order or combine parts incorrectly.
  3. Final Answer:

    /user/123/orders -> Option A
  4. Quick Check:

    Resource then ID then sub-resource = A [OK]
Quick Trick: Put main resource before ID and sub-resource [OK]
Common Mistakes:
MISTAKES
  • Placing ID before resource name
  • Mixing resource and ID order
  • Combining ID and resource without separator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes