Bird
0
0

Which of the following is the correct nested URL format to get comments of a post with ID 5?

easy📝 Syntax Q12 of 15
Rest API - URL and Resource Design
Which of the following is the correct nested URL format to get comments of a post with ID 5?
A/comments/5/posts
B/comments/posts/5
C/posts/5/comments
D/posts/comments/5
Step-by-Step Solution
Solution:
  1. Step 1: Identify parent and child in URL

    The parent is 'posts' with ID 5, and the child is 'comments'. The child comes after the parent.
  2. Step 2: Check URL structure

    The correct format is /parent/{parent_id}/child, so /posts/5/comments is correct.
  3. Final Answer:

    /posts/5/comments -> Option C
  4. Quick Check:

    Parent ID before child resource [OK]
Quick Trick: Parent resource and ID come before child resource in URL [OK]
Common Mistakes:
MISTAKES
  • Placing child resource before parent
  • Swapping IDs and resource names
  • Using incorrect order of URL segments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes