Bird
0
0

You want to design a REST API to manage blog posts. Which URL and HTTP method combination correctly avoids verbs in the URL and uses HTTP methods properly to delete a post with ID 321?

hard📝 Application Q15 of 15
Rest API - URL and Resource Design
You want to design a REST API to manage blog posts. Which URL and HTTP method combination correctly avoids verbs in the URL and uses HTTP methods properly to delete a post with ID 321?
ADELETE /deletePost/321
BDELETE /posts/321
CPOST /posts/321/delete
DGET /posts/delete/321
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct URL structure

    The URL should use a noun representing the resource, here /posts/321, without verbs like 'delete'.
  2. Step 2: Match HTTP method to action

    To delete a resource, use the DELETE method with the resource URL.
  3. Final Answer:

    DELETE /posts/321 -> Option B
  4. Quick Check:

    Delete resource = DELETE + noun URL [OK]
Quick Trick: Use DELETE method with noun URL to remove resource [OK]
Common Mistakes:
MISTAKES
  • Including verbs like 'delete' in the URL
  • Using GET or POST for delete actions
  • Placing action words after resource ID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes