Bird
0
0

You have a REST API for managing tasks with fields: title, completed, and priority. You want to mark a task as completed without changing other fields. Which PATCH request body is best?

hard📝 Application Q15 of 15
Rest API - HTTP Methods
You have a REST API for managing tasks with fields: title, completed, and priority. You want to mark a task as completed without changing other fields. Which PATCH request body is best?
A{"title": "", "completed": true, "priority": null}
B{"completed": true}
C{"completed": true, "priority": "high"}
D{"title": "New Task"}
Step-by-Step Solution
Solution:
  1. Step 1: Identify minimal update needed

    Only the "completed" field needs to change, so send only that.
  2. Step 2: Avoid sending unrelated or empty fields

    Sending empty or null fields may overwrite data unintentionally.
  3. Final Answer:

    {"completed": true} -> Option B
  4. Quick Check:

    Send only changed fields in PATCH body [OK]
Quick Trick: Send only fields you want to update in PATCH [OK]
Common Mistakes:
MISTAKES
  • Sending all fields even if unchanged
  • Sending empty or null values accidentally
  • Using PUT instead of PATCH for partial update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes