But your client expects the code as an integer. What is the best fix?
medium
A. Change the message to "Access Denied"
B. Remove the code field entirely
C. Change the code value to an integer 403 in the response
D. Wrap the code in quotes to make it a string
Solution
Step 1: Identify data type mismatch
The code is a string "403" but the client expects an integer 403.
Step 2: Fix the data type in the response
Change the code value from a string to an integer to match client expectations.
Final Answer:
Change the code value to an integer 403 in the response -> Option C
Quick Check:
Match data types for code field [OK]
Hint: Ensure error code data type matches client expectation [OK]
Common Mistakes:
Removing important error fields
Changing message instead of code type
Leaving code as string when integer needed
5. You want to design an error response format that includes an error code, a message, and optional details for debugging. Which JSON structure below best fits this need?
hard
A. {"error": "Bad Request", "code": 400}
B. {"status": "error", "code": 400, "msg": "Bad Request"}
C. {"error_code": 400, "error_message": "Bad Request"}