0
0
Rest APIprogramming~20 mins

Human-readable error messages in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Human-readable REST API Errors
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this REST API error response?

Consider a REST API that returns this JSON error response when a user tries to access a resource without permission.

{
  "error": {
    "code": 403,
    "message": "Access denied: You do not have permission to view this resource.",
    "details": "User role 'guest' lacks 'read' permission."
  }
}

What is the message field in this error response?

AUnauthorized access attempt detected.
BAccess denied: You do not have permission to view this resource.
CPermission error: guest role cannot read.
DError 403: Forbidden access.
Attempts:
2 left
💡 Hint

Look for the exact text in the message field of the JSON.

Predict Output
intermediate
1:30remaining
What HTTP status code is returned for a missing resource?

A REST API returns this JSON error when a requested item is not found:

{
  "error": {
    "code": 404,
    "message": "Resource not found: The requested item does not exist.",
    "details": "Item ID 12345 not found in database."
  }
}

What is the HTTP status code in this error response?

A500
B401
C400
D404
Attempts:
2 left
💡 Hint

Check the code field inside the error object.

Predict Output
advanced
2:00remaining
What is the user-friendly error message for invalid input?

A REST API returns this error JSON when the user sends invalid data:

{
  "error": {
    "code": 422,
    "message": "Invalid input: 'email' field must be a valid email address.",
    "details": "Value 'user_at_example.com' is not a valid email format."
  }
}

What is the exact message shown to the user?

AInvalid input: 'email' field must be a valid email address.
BError 422: Unprocessable Entity.
CEmail format error: user_at_example.com is invalid.
DInput validation failed for email.
Attempts:
2 left
💡 Hint

Focus on the message field for the user-friendly explanation.

Predict Output
advanced
2:00remaining
What error message does this REST API return for server failure?

When the server encounters an unexpected error, it returns this JSON:

{
  "error": {
    "code": 500,
    "message": "Internal server error: Please try again later.",
    "details": "NullReferenceException at line 42."
  }
}

What is the message field value?

ANullReferenceException occurred.
BServer error 500: Unexpected failure.
CInternal server error: Please try again later.
DService unavailable, try again.
Attempts:
2 left
💡 Hint

Look for the exact text in the message field.

Predict Output
expert
2:30remaining
What is the exact error message returned when authentication fails?

A REST API returns this JSON when authentication fails:

{
  "error": {
    "code": 401,
    "message": "Authentication failed: Invalid API key provided.",
    "details": "API key 'abc123' is not recognized."
  }
}

What is the exact message field value in this error response?

AAuthentication failed: Invalid API key provided.
BError 401: Unauthorized access.
CAPI key abc123 is invalid.
DAccess denied due to invalid credentials.
Attempts:
2 left
💡 Hint

Check the message field for the user-friendly error text.