Bird
Raised Fist0

If a REST API returns this JSON:

medium📝 Predict Output Q5 of Q15
Rest API - Error Handling
If a REST API returns this JSON:
{"errors": {"username": ["Too short", "Invalid characters"]}}

What does this indicate about the 'username' field?
AIt has a server error
BIt is valid
CIt is missing
DIt has multiple validation errors
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the errors array for 'username'

    The value is a list with two messages, indicating multiple errors.
  2. Step 2: Interpret the meaning

    Multiple messages mean the field failed more than one validation rule.
  3. Final Answer:

    It has multiple validation errors -> Option D
  4. Quick Check:

    Array of messages = multiple errors [OK]
Quick Trick: Multiple messages mean multiple errors [OK]
Common Mistakes:
MISTAKES
  • Assuming array means valid data
  • Confusing missing field with multiple errors
  • Thinking server error is indicated here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes