HTTP u0026 REST Essentials: Status Codes, Idempotency, and Advanced Concepts Quiz

This quiz assesses in-depth understanding of HTTP and REST fundamentals, including status codes, idempotency, pagination mechanisms, and robust error handling strategies.

  1. Distinguishing Successful Responses

    When a REST API successfully creates a new resource, which HTTP status code should it return to indicate resource creation, for example after a POST request to /items?

    1. 400 Bad Request
    2. 203 Non-Authoritative Information
    3. 201 Created
    4. 200 Okay
    5. 204 No Content
  2. Understanding Idempotency

    Which HTTP method is inherently designed to be idempotent, meaning that repeating the request multiple times yields the same result as making it once?

    1. CONNECT
    2. PATCH
    3. TRACE
    4. PUT
    5. POST
  3. Recognizing Error Responses

    If a client tries to access a resource that does not exist on the server, such as GET /profiles/999, which HTTP status code is appropriate?

    1. 422 Unprocessable Content
    2. 202 Accepted
    3. 408 Request Timeout
    4. 409 Conflict
    5. 404 Not Found
  4. Pagination Approaches

    Which HTTP header is commonly used to provide clients with a URL to the next page in a paginated set of results when using cursor-based pagination?

    1. Link
    2. Range
    3. Content-Range
    4. Forwarded
    5. Location
  5. Interpreting Safe Methods

    Which HTTP method is considered 'safe', meaning it should not cause any state change on the server when used, for example, to retrieve information from /users?

    1. POST
    2. DELETE
    3. GET
    4. PATCH
    5. UPDATE
  6. Error Handling in REST

    According to REST best practices, what should the response body include when returning a 400 Bad Request status code due to invalid client input?

    1. Only an empty body
    2. A redirect link to the correct resource
    3. A description of the error and possibly details about which inputs were invalid
    4. A stack trace with internal error details
    5. A list of all resources of the same type
  7. Distinguishing Status Codes

    What does the 409 Conflict HTTP status code signify when returned by a REST API, such as after an update to a resource fails due to a version mismatch?

    1. The resource was permanently removed
    2. The payload format is not supported
    3. The request could not be completed due to a resource state conflict
    4. The server does not support the functionality required
    5. Authentication is required and has failed
  8. Idempotent Method Scenarios

    If a client repeatedly sends a DELETE request to /orders/1001 and the resource is already deleted, what status code should a properly designed REST API ideally return for the subsequent requests?

    1. 201 Created
    2. 500 Internal Server Error
    3. 303 See Other
    4. 202 Accepted
    5. 404 Not Found
  9. Pagination Strategies

    In RESTful APIs, which query parameters are commonly used to implement offset-based pagination, for example in GET /products?offset=20u0026limit=10?

    1. from and range
    2. cursor and batch
    3. offset and limit
    4. token and window
    5. next and size
  10. Client Error Response Semantics

    When a PATCH request to /accounts/5 is missing required fields in its payload, which HTTP status code should the server use to indicate that the request was well-formed but semantically incorrect?

    1. 401 Unautherized
    2. 412 Precondition Failed
    3. 304 Not Modified
    4. 502 Bad Gateway
    5. 422 Unprocessable Entity