What is the correct HTTP method and URL to retrieve a list of books without verbs in the URL?
medium📝 Predict Output Q4 of 15
Rest API - URL and Resource Design
What is the correct HTTP method and URL to retrieve a list of books without verbs in the URL?
ADELETE /books/list
BPOST /getBooks
CGET /books
DGET /fetchBooks
Step-by-Step Solution
Solution:
Step 1: Identify the action and resource
Retrieving data uses the GET method, and the resource is 'books'.
Step 2: Check URL for verbs
GET /books uses GET and '/books' without verbs. DELETE /books/list uses the incorrect DELETE method for retrieval, while '/getBooks' and '/fetchBooks' include verbs in the URL.
Final Answer:
GET /books -> Option C
Quick Check:
GET + noun URL = GET /books [OK]
Quick Trick:Use GET with resource noun URL to retrieve data [OK]
Common Mistakes:
MISTAKES
Using POST or DELETE for retrieval
Including verbs in URL paths
Confusing HTTP method with URL action
Master "URL and Resource Design" in Rest API
9 interactive learning modes - each teaches the same concept differently