Bird
0
0

You want to design a REST API URL to access the third photo in album 10 of user 5. Which URL correctly identifies this resource?

hard📝 Application Q8 of 15
Rest API - URL and Resource Design
You want to design a REST API URL to access the third photo in album 10 of user 5. Which URL correctly identifies this resource?
A/users/5/albums/10/photos/3
B/photos/3/albums/10/users/5
C/users/5/photos/3/albums/10
D/albums/10/users/5/photos/3
Step-by-Step Solution
Solution:
  1. Step 1: Understand resource hierarchy

    User is the top-level resource, then albums, then photos inside albums.
  2. Step 2: Check URL order

    /users/5/albums/10/photos/3 correctly follows the hierarchy: user 5 > album 10 > photo 3.
  3. Step 3: Eliminate incorrect orders

    Options B, C, and D mix the order, breaking the logical nesting.
  4. Final Answer:

    /users/5/albums/10/photos/3 -> Option A
  5. Quick Check:

    URL order matches resource nesting [OK]
Quick Trick: Nest URLs from parent to child resource [OK]
Common Mistakes:
  • Mixing resource order in URL
  • Skipping parent resources
  • Placing child before parent

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes