Bird
0
0

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:
  1. Step 1: Understand REST syntax for single resource

    Single resources are accessed by appending the resource ID to the plural noun.
  2. 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.
  3. Final Answer:

    /articles/789 -> Option D
  4. 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

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes