Test your understanding of essential HTTP and REST principles, including status codes, pagination methods, retry strategies, and idempotency concepts. This quiz is designed for beginners to reinforce foundational knowledge of web and API communication standards.
Which HTTP status code indicates that a client's request was successfully received, understood, and accepted?
Explanation: The 200 OK status code signals that the request was processed successfully by the server. 404 Not Found means the resource is missing, 301 Moved Permanent is a redirection code, and 500 Internal Error shows a server error. Only 200 OK represents a standard successful response.
What does the HTTP status code 404 signify when accessing an API endpoint?
Explanation: A 404 status means the server could not locate the requested resource. The code does not indicate a successful request, a need for authentication (which would be 401), or a redirection (such as 302 or 301). Thus, it signals the absence of the resource.
Why is pagination commonly used in REST API responses that return large lists, such as results from a 'Get All Users' endpoint?
Explanation: Pagination divides large result sets into smaller, more manageable pages for easier consumption and to avoid overwhelming clients or networks. Data encryption and hiding sensitive fields are unrelated to pagination, while increasing status codes is not a purpose of pagination.
What type of issue does an HTTP status code in the 4xx range, such as 403, represent?
Explanation: 4xx status codes indicate client-side issues, where the request is invalid in some way. Successful requests use 2xx codes, server-side errors use 5xx codes, and timeouts are not directly represented by 4xx codes.
Which HTTP status code should a REST API return after successfully creating a new resource, for example, after a POST request?
Explanation: 201 Created is explicitly used when a new resource is made following client input. 204 No Content means the request was successful with no content to return, 304 Not Modified is for caching scenarios, and 400 Bad Syntax represents an invalid request.
In REST, what does it mean if an HTTP method is idempotent when handling a request like DELETE on a resource?
Explanation: Idempotent operations produce the same result, no matter how many times the operation is performed. Changing results each time, returning random codes, or creating resources are not properties associated with idempotency.
Which HTTP header might a server use to indicate how long a client should wait before retrying a request due to temporary overload (such as after receiving a 503 Service Unavailable)?
Explanation: Retry-After guides clients on when to retry after receiving temporary errors like 503. Set-Cookie relates to session management, Content-Encoding handles data formats, and Accept-Language specifies language preferences, none of which are for retry timing.
Which HTTP method is considered safe because it does not modify any resources, such as when retrieving data using an endpoint?
Explanation: GET requests are safe as they only retrieve data and have no side effects. DELETE, PATCH, and POST can all alter resource states, making them unsafe in this context.
If you receive an HTTP 500 status from a REST API, what does this typically indicate?
Explanation: A 500 status points to a general server error. Invalid client requests cause 4xx errors, not 500. Status 301 signals permanent redirection, and pagination is separate from status codes indicating server issues.
Which query parameter is frequently used to specify how many items are returned per page in a paginated REST API?
Explanation: The 'limit' parameter controls the maximum number of results per page. 'Expand' may request more details, 'action' is not related to pagination, and 'filter_by' filters data, not page size.
What is the main idea behind using exponential backoff when retrying failed HTTP requests?
Explanation: Exponential backoff increases the delay between each retry to reduce server overload. Decreasing delay or no delay can worsen the problem. The order of request names has nothing to do with retry or backoff logic.
Which HTTP status code means that authentication is required and has failed or not been provided, such as when accessing restricted data?
Explanation: 401 Unauthorized indicates missing or failed authentication. 403 Forbidden signals that access is not permitted even if authenticated. 200 OK is for success, and 302 Found is a redirection response.
Which HTTP method is typically idempotent when updating a resource, such as user profile information in REST APIs?
Explanation: PUT is idempotent, so repeating the same request does not change the outcome, which is ideal for updates. POST is not idempotent, as it can create multiple resources. OPTIONS and CONNECT serve different protocol negotiation purposes.
When an HTTP request is successful but there is no content to return, such as after a DELETE request, which status code is suitable?
Explanation: 204 No Content signals success with no data returned. 422 means the request is semantic but unprocessable, 302 is for redirection, and 207 handles multiple responses in complex scenarios, none of which match this requirement.
In paginated API responses, what is the function of a 'next' link provided in the response body?
Explanation: A 'next' link points to the next page of results in pagination. It does not handle encryption, updating statuses, or deleting resources, which are unrelated actions.
Which HTTP status code most likely suggests that a client can retry the request later, such as when a server is temporarily overloaded?
Explanation: 503 Service Unavailable informs the client that the server cannot handle the request now but may be available later, making retries reasonable. 201 Created is for successful resource creation, 403 is for forbidden access, and 307 is for redirection, not overload.