Bird
0
0

To update a blog post with ID 101 following REST best practices and avoiding verbs in the URL, which HTTP method and URL combination is correct?

hard📝 Application Q8 of 15
Rest API - URL and Resource Design
To update a blog post with ID 101 following REST best practices and avoiding verbs in the URL, which HTTP method and URL combination is correct?
APUT /modifyPost/101
BPOST /updatePost/101
CPATCH /editPost/101
DPUT /posts/101
Step-by-Step Solution
Solution:
  1. Step 1: Identify verbs in URLs

    Options B, C, and D contain verbs like 'update', 'edit', and 'modify' in the URL path, which is against REST guidelines.
  2. Step 2: Choose correct HTTP method

    PUT is the standard method for full updates of a resource.
  3. Step 3: Select URL without verbs

    PUT /posts/101 uses a noun resource path without verbs and the correct HTTP method.
  4. Final Answer:

    PUT /posts/101 -> Option D
  5. Quick Check:

    Use nouns in URLs and HTTP methods for actions. [OK]
Quick Trick: Use resource nouns in URLs and HTTP verbs for actions [OK]
Common Mistakes:
MISTAKES
  • Including verbs in the URL path
  • Using POST for updates instead of PUT or PATCH

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes