0
0
Rest APIprogramming~20 mins

404 Not Found in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
404 Not Found Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:00remaining
What is the HTTP status code returned when a requested resource is not found?
When a client requests a resource from a REST API that does not exist, what HTTP status code should the server return?
A404 Not Found
B200 OK
C500 Internal Server Error
D301 Moved Permanently
Attempts:
2 left
💡 Hint
Think about the code that means the resource is missing.
Predict Output
intermediate
1:30remaining
What is the typical JSON response body for a 404 Not Found error?
A REST API returns a 404 Not Found status. Which JSON response body best describes this error?
A{"message": "Internal server error"}
B{"success": true}
C{"error": "Resource not found"}
D{"redirect": "/home"}
Attempts:
2 left
💡 Hint
The response should explain the resource is missing.
🔧 Debug
advanced
2:00remaining
Why does this REST API endpoint return 404 Not Found unexpectedly?
Given this code snippet for a REST API endpoint, why might it return 404 Not Found even when the resource exists? ```python @app.route('/items/') def get_item(item_id): item = database.get(item_id) if not item: return {'error': 'Item not found'}, 404 return item ``` Options:
AThe database.get(item_id) returns None because item_id is a string, not an int
BThe route expects an integer but the client sends a string, so the route does not match
CThe function returns 404 even if the item exists due to a missing return statement
DThe server is down, causing all requests to return 404
Attempts:
2 left
💡 Hint
Check the route parameter type and what the client sends.
🧠 Conceptual
advanced
1:30remaining
What is the difference between 404 Not Found and 410 Gone in REST APIs?
Which statement correctly explains the difference between HTTP status codes 404 Not Found and 410 Gone?
A404 means the resource is temporarily missing; 410 means it is permanently removed
B404 means the resource is permanently removed; 410 means it is temporarily missing
C404 and 410 mean the same and can be used interchangeably
D404 means server error; 410 means client error
Attempts:
2 left
💡 Hint
Think about temporary vs permanent absence.
📝 Syntax
expert
2:00remaining
Which code snippet correctly returns a 404 Not Found response with a custom message in a Node.js Express app?
Choose the code that sends a 404 status with JSON message 'Page not found' in Express.js:
Ares.status(404).send({message: 'Page not found'})
Bres.send(404, {message: 'Page not found'})
Cres.sendStatus(404).json({message: 'Page not found'})
Dres.status(404).json({message: 'Page not found'})
Attempts:
2 left
💡 Hint
Check the correct method to send JSON with status.