Bird
0
0

You have this error response from a REST API:

medium📝 Debug Q14 of 15
Rest API - Advanced Patterns
You have this error response from a REST API:
{
  "error": "Invalid ID",
  "code": 400
}

But your client expects error details under the key "message" instead of "error". How can you fix this to follow consistent error patterns?
AChange the API to return {"message": "Invalid ID", "code": 400}
BChange the client to look for "error" key instead of "message"
CIgnore the error and retry the request
DRemove the "code" key from the response
Step-by-Step Solution
Solution:
  1. Step 1: Identify the inconsistency

    The API returns error details under "error" but client expects "message" key.
  2. Step 2: Fix the API response to match client expectation

    Change the API to use "message" key for error details to keep consistent error format.
  3. Final Answer:

    Change the API to return {"message": "Invalid ID", "code": 400} -> Option A
  4. Quick Check:

    Consistent error keys = Use "message" key in API response [OK]
Quick Trick: Match error keys between API and client [OK]
Common Mistakes:
MISTAKES
  • Ignoring client expectations
  • Retrying without fixing error format
  • Removing important error code info

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes