Bird
0
0

You have this JSON response from an uptime API: {"uptime_percentage": "99.9", "downtime_minutes": 43}. The API client code expects uptime_percentage as a float. What is the likely error?

medium📝 Debug Q6 of 15
Rest API - API Testing and Monitoring
You have this JSON response from an uptime API: {"uptime_percentage": "99.9", "downtime_minutes": 43}. The API client code expects uptime_percentage as a float. What is the likely error?
ASyntaxError in JSON format
BTypeError due to string instead of float
CNo error, string is acceptable
DKeyError for missing uptime_percentage
Step-by-Step Solution
Solution:
  1. Step 1: Identify data type mismatch

    uptime_percentage is a string "99.9" but client expects a float number.
  2. Step 2: Understand error consequences

    Using string where float expected causes TypeError during calculations.
  3. Final Answer:

    TypeError due to string instead of float -> Option B
  4. Quick Check:

    Data type mismatch = TypeError [OK]
Quick Trick: Match JSON data types to client expectations [OK]
Common Mistakes:
MISTAKES
  • Assuming JSON string is auto-converted
  • Thinking JSON syntax is invalid
  • Confusing missing keys with type errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes