Rest API - URL and Resource DesignWhich of the following is a correct REST API URL structure for accessing comments of a blog post?A/comments/post/{postId}/getB/comments/postIdC/posts/{postId}/commentsD/getComments?post={postId}Check Answer
Step-by-Step SolutionSolution:Step 1: Identify correct URL pattern for nested resourcesREST URLs use nested paths to show resource relationships, so comments belong under posts.Step 2: Check each option's structure/posts/{postId}/comments uses '/posts/{postId}/comments' which correctly nests comments under a specific post.Final Answer:/posts/{postId}/comments -> Option CQuick Check:Nested resource URLs = /posts/{postId}/comments [OK]Quick Trick: Use nested paths for related resources [OK]Common Mistakes:MISTAKESUsing query parameters instead of pathPlacing resource IDs incorrectlyAdding verbs in URL path
Master "URL and Resource Design" in Rest API9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Rest API Quizzes HTTP Methods - DELETE for removing resources - Quiz 7medium HTTP Status Codes - 200 OK and 201 Created - Quiz 12easy Query Parameters and Filtering - Sort direction (asc, desc) - Quiz 9hard REST API Fundamentals - Statelessness requirement - Quiz 7medium REST API Fundamentals - REST vs SOAP vs GraphQL comparison - Quiz 10hard Request and Response Format - Why consistent formats improve usability - Quiz 15hard Request and Response Format - Response envelope patterns - Quiz 2easy Request and Response Format - Response headers (Cache-Control, ETag) - Quiz 4medium URL and Resource Design - Query parameters for filtering - Quiz 5medium URL and Resource Design - Nested resources - Quiz 14medium