Which of the following is the correct way to include a resource identifier for a user with ID 42 in a REST API URL?
easy📝 Syntax Q12 of 15
Rest API - URL and Resource Design
Which of the following is the correct way to include a resource identifier for a user with ID 42 in a REST API URL?
A/users#42
B/users?id=42
C/users/42/details
D/users/42
Step-by-Step Solution
Solution:
Step 1: Identify the standard REST URL format
Resource identifiers usually come directly after the resource name separated by a slash.
Step 2: Check each option
/users/42 uses "/users/42" which correctly places the ID after the resource name. /users?id=42 uses a query parameter, which is less common for resource identification. /users/42/details adds extra path which may refer to a sub-resource. /users#42 uses a fragment which is not for resource IDs.
Final Answer:
/users/42 -> Option D
Quick Check:
Resource ID follows resource name with slash [OK]
Quick Trick:Resource ID follows resource name with a slash / [OK]
Common Mistakes:
Using query parameters instead of path segments
Adding extra path parts that change meaning
Using URL fragments (#) for resource IDs
Master "URL and Resource Design" in Rest API
9 interactive learning modes - each teaches the same concept differently