Which of the following REST API endpoints correctly accesses a single article resource with ID 789?
easy📝 Syntax Q3 of 15
Rest API - URL and Resource Design
Which of the following REST API endpoints correctly accesses a single article resource with ID 789?
A/article/789/view
B/getArticle/789
C/articles?id=789
D/articles/789
Step-by-Step Solution
Solution:
Step 1: Understand REST syntax for single resource
Single resources are accessed by appending the resource ID to the plural noun.
Step 2: Analyze options
/articles/789 correctly uses '/articles/789'. /getArticle/789 uses a verb 'get', /articles?id=789 uses query parameters which is less RESTful for single resource, /article/789/view adds extra action words.
Final Answer:
/articles/789 -> Option D
Quick Check:
Plural noun + ID path segment [OK]
Quick Trick:Use /resourcePlural/{id} for single resource [OK]
Common Mistakes:
Using verbs in endpoint paths
Using query parameters for resource ID
Adding extra action words in path
Master "URL and Resource Design" in Rest API
9 interactive learning modes - each teaches the same concept differently