Bird
0
0

You see this API request: POST /users/45. What is wrong with this request in resource-based design?

medium📝 Debug Q14 of 15
Rest API - REST API Fundamentals
You see this API request: POST /users/45. What is wrong with this request in resource-based design?
AThe URL should be <code>/users</code> without ID for creating
BPOST cannot be used to create resources
CThe HTTP method should be PUT
DPOST must include a resource ID in the URL
Step-by-Step Solution
Solution:
  1. Step 1: Understand POST usage in REST

    POST is used to create new resources. The URL should point to the collection, not a specific resource ID.
  2. Step 2: Analyze the request URL

    Including an ID (like /users/45) with POST is incorrect because the server assigns IDs when creating new resources.
  3. Final Answer:

    The URL should be /users without ID for creating -> Option A
  4. Quick Check:

    POST to collection URL without ID = correct [OK]
Quick Trick: POST creates; URL should be collection without ID [OK]
Common Mistakes:
MISTAKES
  • Using POST with resource ID in URL
  • Thinking POST updates existing resource
  • Confusing POST and PUT URLs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes