Bird
0
0

Why is the following HTTP method usage incorrect?

medium📝 Debug Q7 of 15
Rest API - HTTP Methods
Why is the following HTTP method usage incorrect?
POST /items/123 HTTP/1.1
Content-Type: application/json

{"price": 10}
given that the client wants to update the price of item 123.
APOST cannot send JSON data
BPOST should not be used to update existing resources
CThe JSON body is missing required fields
DContent-Type header is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Understand HTTP method semantics

    POST is mainly for creating resources, not updating existing ones.
  2. Step 2: Identify correct method for update

    PUT or PATCH should be used to update existing resources.
  3. Final Answer:

    POST should not be used to update existing resources -> Option B
  4. Quick Check:

    Update method = PUT/PATCH, not POST [OK]
Quick Trick: Use PUT or PATCH to update, not POST [OK]
Common Mistakes:
  • Using POST to update
  • Ignoring correct Content-Type
  • Assuming POST cannot send JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes