HTTP u0026 REST Fundamentals Quiz Quiz

Test your basic knowledge of HTTP methods, REST concepts, important status codes, idempotency, and pagination in RESTful APIs. This quiz helps you understand key elements essential for working with modern web APIs and client-server communication.

  1. HTTP GET Method Basics

    Which HTTP method should be used to retrieve data from a server without causing any side effects?

    1. GET
    2. PUSH
    3. POST
    4. SEND

    Explanation: GET is designed for retrieving data and does not modify resources, making it safe and idempotent. SEND is not an HTTP method and PUSH is also incorrect in this context. POST is used for creating or submitting data, and often results in changes on the server.

  2. Success Status Code

    After a client successfully retrieves a resource, which HTTP status code is most appropriate to indicate success?

    1. 404 Not Found
    2. 200 OK
    3. 500 Server Error
    4. 302 Found

    Explanation: 200 OK indicates that the request has succeeded, which is appropriate for successful retrievals. 404 Not Found signals that the resource could not be found, 500 Server Error means a server-side problem occurred, and 302 Found indicates a temporary redirect, not a successful retrieval.

  3. Creating Resources

    Which HTTP method is typically used to create a new resource on the server, such as submitting a registration form?

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

    Explanation: POST is used to request that the server create a new resource, such as handling form submissions. PATCH is for making partial updates, DELETE removes resources, and FETCH is not a standard HTTP method.

  4. Identifying Status Code Categories

    Which range of HTTP status codes indicates client errors, such as a malformed request?

    1. 200–299
    2. 400–499
    3. 100–199
    4. 500–599

    Explanation: HTTP status codes from 400–499 represent client-side errors, like bad requests (400) or unauthorized access (401). 100–199 are informational, 500–599 are server-side errors, and 200–299 indicate successful responses.

  5. Idempotency Definition

    What does it mean when an HTTP method is described as 'idempotent'?

    1. It is only allowed once per session
    2. Repeating the request has the same effect as making it once
    3. It always creates a new resource
    4. It returns different results with each call

    Explanation: An idempotent method produces the same result, no matter how many times it is called with the same parameters. Methods that always create new resources (like POST) are not idempotent. Returning different results or limiting use per session does not define idempotency.

  6. Deleting a Resource

    If you want to remove an existing item from a RESTful API, which HTTP method should you use?

    1. PUT
    2. CONNECT
    3. UPDATE
    4. DELETE

    Explanation: DELETE is explicitly used to remove resources in RESTful APIs. PUT is meant for completely replacing a resource, UPDATE is not a standard HTTP method, and CONNECT is used for establishing a tunnel, not deleting resources.

  7. Why Use Pagination?

    Why is pagination commonly used in RESTful APIs when returning lists of items, such as search results?

    1. To randomize the item order
    2. To perform calculations more quickly
    3. To limit the amount of data returned in each response
    4. To encrypt the data automatically

    Explanation: Pagination breaks large datasets into smaller chunks, making responses faster and easier to handle. It does not automatically encrypt data, perform calculations, or randomize item order—these options are incorrect in the context of pagination.

  8. Status Code for Non-Existent Resources

    What HTTP status code is returned when a client requests a resource that does not exist on the server?

    1. 204 No Content
    2. 201 Created
    3. 404 Not Found
    4. 303 See Also

    Explanation: 404 Not Found means the requested resource is not available. 201 Created is for successful creation, 303 See Also is a redirect, and 204 No Content means the request was successful but there is no content to return.

  9. Safe Methods in HTTP

    Which one of these HTTP methods is considered 'safe,' meaning it does not modify the server state?

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

    Explanation: HEAD retrieves metadata about a resource but does not alter server state, making it safe. PATCH and POST are used for modifying or creating resources, while DELETE removes resources, so they are not safe.

  10. Common Pagination Parameters

    Which pair of query parameters is most often used in REST API pagination to navigate between pages of data?

    1. skip and fetch
    2. page and limit
    3. total and count
    4. user and data

    Explanation: page and limit are widely used in REST APIs for pagination—'page' specifies which page and 'limit' specifies how many items per page. total and count, skip and fetch, user and data are either not standard pairs or refer to other data concepts.