Bird
0
0

Which of the following is a correct REST API URL structure for accessing comments of a blog post?

easy📝 Syntax Q3 of 15
Rest API - URL and Resource Design
Which of the following is a correct REST API URL structure for accessing comments of a blog post?
A/comments/post/{postId}/get
B/comments/postId
C/posts/{postId}/comments
D/getComments?post={postId}
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct URL pattern for nested resources

    REST URLs use nested paths to show resource relationships, so comments belong under posts.
  2. Step 2: Check each option's structure

    /posts/{postId}/comments uses '/posts/{postId}/comments' which correctly nests comments under a specific post.
  3. Final Answer:

    /posts/{postId}/comments -> Option C
  4. Quick Check:

    Nested resource URLs = /posts/{postId}/comments [OK]
Quick Trick: Use nested paths for related resources [OK]
Common Mistakes:
MISTAKES
  • Using query parameters instead of path
  • Placing resource IDs incorrectly
  • Adding verbs in URL path

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes