Bird
0
0

What is wrong with this nested resource URL for deleting a comment: /comments/10/posts/5?

medium📝 Debug Q7 of 15
Rest API - URL and Resource Design
What is wrong with this nested resource URL for deleting a comment: /comments/10/posts/5?
AThe parent resource should come before the child
BIDs are in the wrong order
CHTTP method DELETE cannot be used here
DURL should not include IDs
Step-by-Step Solution
Solution:
  1. Step 1: Analyze resource order

    The URL shows child resource 'comments' before parent 'posts', which is incorrect.
  2. Step 2: Correct order for nested resources

    Parent resource must come first, so it should be /posts/5/comments/10.
  3. Final Answer:

    The parent resource should come before the child -> Option A
  4. Quick Check:

    Parent resource always precedes child in URL [OK]
Quick Trick: Parent resource always first in nested URLs [OK]
Common Mistakes:
MISTAKES
  • Swapping parent and child resource order
  • Confusing HTTP methods with URL structure
  • Omitting IDs thinking they are optional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes