Challenge - 5 Problems
REST API Safe Methods Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:00remaining
Which HTTP method is considered safe?
In REST APIs, safe methods are those that do not change server data. Which of the following HTTP methods is safe?
Attempts:
2 left
💡 Hint
Safe methods are used only to retrieve data without side effects.
✗ Incorrect
GET is a safe method because it only retrieves data and does not modify any resource on the server.
🧠 Conceptual
intermediate1:00remaining
Which HTTP method is unsafe and used to update resources?
Unsafe methods can change server data. Which HTTP method below is unsafe and typically used to update an existing resource?
Attempts:
2 left
💡 Hint
Updating means changing data on the server.
✗ Incorrect
PUT is unsafe because it modifies or replaces the resource on the server.
❓ Predict Output
advanced1:30remaining
What is the output status code for a safe GET request?
Consider this HTTP request made to a REST API endpoint that returns data without changing anything. What is the typical HTTP status code returned?
Rest API
GET /api/items/123 HTTP/1.1 Host: example.com
Attempts:
2 left
💡 Hint
Successful GET requests usually return the requested data.
✗ Incorrect
A 200 OK status means the GET request succeeded and the server returned the requested data.
❓ Predict Output
advanced1:30remaining
What error occurs if a DELETE method is sent to a read-only API?
If you send a DELETE request to an API that only allows safe methods, what HTTP status code will the server most likely return?
Rest API
DELETE /api/items/123 HTTP/1.1 Host: example.com
Attempts:
2 left
💡 Hint
The server rejects methods it does not support.
✗ Incorrect
405 Method Not Allowed means the server understands the method but refuses to allow it on the resource.
🧠 Conceptual
expert2:00remaining
Why are safe methods important for caching in REST APIs?
Safe methods like GET are often cached by browsers and proxies. Why is caching safe methods important in REST API design?
Attempts:
2 left
💡 Hint
Think about how caching helps when data does not change.
✗ Incorrect
Safe methods do not change data, so their responses can be cached safely to speed up repeated requests without causing incorrect data to be shown.