Bird
0
0

Which of the following is the correct syntax for a hierarchical resource path to access comments of a post with ID 10?

easy📝 Syntax Q12 of 15
Rest API - URL and Resource Design
Which of the following is the correct syntax for a hierarchical resource path to access comments of a post with ID 10?
A/posts/10/comments
B/comments/posts/10
C/posts/comments/10
D/10/posts/comments
Step-by-Step Solution
Solution:
  1. Step 1: Identify the parent resource and its ID

    The parent resource is 'posts' with ID 10, so it comes first in the path.
  2. Step 2: Append the child resource

    Comments belong to the post, so '/comments' follows '/posts/10'.
  3. Final Answer:

    /posts/10/comments -> Option A
  4. Quick Check:

    Parent resource + ID + child resource = /posts/10/comments [OK]
Quick Trick: Parent resource and ID come before child resource [OK]
Common Mistakes:
  • Placing child resource before parent
  • Swapping resource names and IDs
  • Using incorrect order of segments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes