Bird
0
0

How would you structure a REST API URL to update the status of task 42 in project 7 for user 3?

hard📝 Application Q9 of 15
Rest API - URL and Resource Design
How would you structure a REST API URL to update the status of task 42 in project 7 for user 3?
A/tasks/42/projects/7/users/3/status
B/users/3/projects/7/tasks/42/status
C/users/3/tasks/42/projects/7/status
D/projects/7/users/3/tasks/42/status
Step-by-Step Solution
Solution:
  1. Step 1: Identify resource hierarchy

    User is top-level, then projects, then tasks inside projects.
  2. Step 2: Confirm URL path order

    /users/3/projects/7/tasks/42/status correctly orders resources: user 3 > project 7 > task 42 > status.
  3. Step 3: Exclude incorrect orders

    Options A, C, and D have resources in wrong order, breaking hierarchy.
  4. Final Answer:

    /users/3/projects/7/tasks/42/status -> Option B
  5. Quick Check:

    URL matches nested resource path [OK]
Quick Trick: Follow resource nesting for update URLs [OK]
Common Mistakes:
MISTAKES
  • Incorrect resource order
  • Skipping parent resources
  • Placing status before task ID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes