Bird
0
0

What is incorrect about this REST API request for creating a new user: PUT /users/123 with user data in the body?

medium📝 Debug Q6 of 15
Rest API - REST API Fundamentals
What is incorrect about this REST API request for creating a new user: PUT /users/123 with user data in the body?
APUT should not be used to create a resource with a client-assigned ID
BThe URI should not include the user ID when creating a new user
CPUT requests must not contain a request body
DThe HTTP method should be GET for creating resources
Step-by-Step Solution
Solution:
  1. Step 1: Understand resource creation conventions

    POST is typically used to create resources when the server assigns the ID.
  2. Step 2: Analyze the URI usage

    Including an ID in the URI implies the resource exists or is being replaced.
  3. Step 3: Identify the error

    Using PUT with a client-assigned ID is allowed but uncommon; however, creating a new user usually uses POST without an ID in the URI.
  4. Final Answer:

    The URI should not include the user ID when creating a new user -> Option B
  5. Quick Check:

    Creation URIs usually omit IDs [OK]
Quick Trick: Create with POST to collection URI, not PUT with ID [OK]
Common Mistakes:
  • Using PUT with client-generated IDs for creation
  • Including IDs in URIs for new resource creation
  • Confusing POST and PUT semantics

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes