Bird
0
0

Why is it important to include both an HTTP status code and an error code inside the JSON error response in a REST API?

hard📝 Conceptual Q10 of 15
Rest API - Request and Response Format
Why is it important to include both an HTTP status code and an error code inside the JSON error response in a REST API?
AError codes replace HTTP status codes completely
BHTTP status codes are optional if error codes exist
CIncluding both slows down the API response
DHTTP status codes provide protocol-level info; error codes give app-specific details
Step-by-Step Solution
Solution:
  1. Step 1: Understand HTTP status codes

    They indicate general success or failure at the protocol level.
  2. Step 2: Understand error codes in JSON

    They provide specific reasons or categories for the error within the application.
  3. Final Answer:

    HTTP status codes provide protocol-level info; error codes give app-specific details -> Option D
  4. Quick Check:

    Both codes serve different but complementary roles [OK]
Quick Trick: Use HTTP and app error codes together for clarity [OK]
Common Mistakes:
  • Thinking error codes replace HTTP status codes
  • Assuming HTTP codes are optional
  • Believing including both slows API

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes