Bird
0
0

You have this nested route defined: /projects/{projectId}/tasks/{taskId}. Which URL is incorrect to get task 7 of project 2?

medium📝 Debug Q14 of 15
Rest API - URL and Resource Design
You have this nested route defined: /projects/{projectId}/tasks/{taskId}. Which URL is incorrect to get task 7 of project 2?
A/projects/2/tasks/7/
B/projects/2/tasks/7
C/projects/2/tasks/07
D/tasks/7/projects/2
Step-by-Step Solution
Solution:
  1. Step 1: Check correct nested URL format

    The correct format is /projects/{projectId}/tasks/{taskId}, so project ID comes before task ID.
  2. Step 2: Identify incorrect URL

    /tasks/7/projects/2 reverses the order to /tasks/7/projects/2, which breaks nesting rules.
  3. Final Answer:

    /tasks/7/projects/2 -> Option D
  4. Quick Check:

    Parent resource must come before child in URL [OK]
Quick Trick: Parent resource always precedes child resource in nested URLs [OK]
Common Mistakes:
MISTAKES
  • Swapping parent and child in URL
  • Adding trailing slashes incorrectly
  • Using leading zeros in IDs (usually allowed but check API)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes