Bird
0
0

What will happen if a PATCH request is sent with an empty JSON body {} to update a resource?

medium📝 Predict Output Q5 of 15
Rest API - HTTP Methods
What will happen if a PATCH request is sent with an empty JSON body {} to update a resource?
AThe resource will be replaced with an empty object.
BThe resource will remain unchanged and the server may return 204 No Content.
CThe server will return a 400 Bad Request error.
DThe resource will be deleted.
Step-by-Step Solution
Solution:
  1. Step 1: Consider PATCH with empty body

    Empty JSON means no fields to update, so resource stays the same.
  2. Step 2: Server response to no changes

    Server usually returns 204 No Content to indicate success with no changes.
  3. Final Answer:

    The resource will remain unchanged and the server may return 204 No Content. -> Option B
  4. Quick Check:

    Empty PATCH body = no change [OK]
Quick Trick: Empty PATCH body means no update, expect 204 [OK]
Common Mistakes:
  • Assuming empty body deletes resource
  • Expecting error on empty body
  • Thinking resource resets to empty

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes