HTTP u0026 REST Fundamentals: Status Codes, Pagination, Retries, and Idempotency Quiz

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.

  1. Identifying a Success Code

    Which HTTP status code indicates that a client's request was successfully received, understood, and accepted?

    1. 200 OK
    2. 500 Internal Error
    3. 404 Not Found
    4. 301 Moved Permanent

    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.

  2. Purpose of Status Code 404

    What does the HTTP status code 404 signify when accessing an API endpoint?

    1. The request was successful
    2. The request needs authentication
    3. The request was redirected
    4. The resource was not found

    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.

  3. Pagination Purpose in APIs

    Why is pagination commonly used in REST API responses that return large lists, such as results from a 'Get All Users' endpoint?

    1. To hide sensitive fields
    2. To increase status codes
    3. To avoid data encryption
    4. To make smaller, manageable responses

    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.

  4. Recognizing a Client Error Code

    What type of issue does an HTTP status code in the 4xx range, such as 403, represent?

    1. A client-side error
    2. A network timeout
    3. A server-side error
    4. A successful request

    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.

  5. Status Code for Resource Creation

    Which HTTP status code should a REST API return after successfully creating a new resource, for example, after a POST request?

    1. 400 Bad Syntax
    2. 204 No Content
    3. 304 Not Modified
    4. 201 Created

    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.

  6. Idempotency Explained

    In REST, what does it mean if an HTTP method is idempotent when handling a request like DELETE on a resource?

    1. It always creates new resources
    2. Multiple identical requests have the same effect
    3. The resource changes differently every time
    4. It returns random status codes

    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.

  7. Retry After Header Usage

    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)?

    1. Accept-Language
    2. Content-Encoding
    3. Retry-After
    4. Set-Cookie

    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.

  8. Safe Methods in REST

    Which HTTP method is considered safe because it does not modify any resources, such as when retrieving data using an endpoint?

    1. DELETE
    2. GET
    3. POST
    4. PATCH

    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.

  9. Interpreting Status 500

    If you receive an HTTP 500 status from a REST API, what does this typically indicate?

    1. Requested data was paginated
    2. The resource was permanently moved
    3. The client sent an invalid request
    4. There is a problem with the server

    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.

  10. Common Pagination Parameter

    Which query parameter is frequently used to specify how many items are returned per page in a paginated REST API?

    1. action
    2. expand
    3. filter_by
    4. limit

    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.

  11. Backoff Strategy in Retries

    What is the main idea behind using exponential backoff when retrying failed HTTP requests?

    1. Decrease wait time after each attempt
    2. Wait a longer amount of time after each retry
    3. Retry without any delay
    4. Send requests in alphabetical order

    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.

  12. Status for Unauthorized

    Which HTTP status code means that authentication is required and has failed or not been provided, such as when accessing restricted data?

    1. 403 Forbidden
    2. 401 Unauthorized
    3. 302 Found
    4. 200 OK

    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.

  13. PUT vs POST Idempotency

    Which HTTP method is typically idempotent when updating a resource, such as user profile information in REST APIs?

    1. CONNECT
    2. POST
    3. OPTIONS
    4. PUT

    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.

  14. Status for Empty Successful Response

    When an HTTP request is successful but there is no content to return, such as after a DELETE request, which status code is suitable?

    1. 204 No Content
    2. 302 Redirect
    3. 422 Unprocessable
    4. 207 Multi-Status

    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.

  15. Purpose of the 'next' Link

    In paginated API responses, what is the function of a 'next' link provided in the response body?

    1. To retrieve the next set of results
    2. To delete the previous items
    3. To encrypt the data
    4. To update resource status

    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.

  16. Handling a Retryable Error

    Which HTTP status code most likely suggests that a client can retry the request later, such as when a server is temporarily overloaded?

    1. 201 Created
    2. 403 Forbidden
    3. 503 Service Unavailable
    4. 307 Temporary Redirect

    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.