REST Easy: A Beginner's Quiz on HTTP Methods and REST Basics Quiz

  1. Meaning of REST and resources

    What does REST stand for, and what is a 'resource' in this context?

    1. Representational State Transfer; a resource is any addressable piece of information such as a user, order, or image
    2. Remote Execution State Transfer; a resource is only a row in a database table
    3. Representational Stateless Transport; a resource is only a static file
    4. Resource Exchange over State Transfer; a resource is the physical server machine
    5. Relational State Transmission; a resource is just an IP address
  2. Correct method to read data

    Which HTTP method should you use to retrieve data without changing it, for example GET /products?category=books?

    1. GET
    2. POST
    3. PUT
    4. PATCH
    5. DELETE
  3. Creating a new resource

    Which HTTP method is commonly used to create a new resource under a collection, for example sending a JSON body to /comments to add one comment?

    1. POST
    2. GET
    3. DELETE
    4. CONNECT
    5. POTS
  4. PUT vs PATCH updates

    When updating a user's profile where only the email changes, what is the typical difference between using PUT /users/7 versus PATCH /users/7?

    1. PUT typically replaces the entire resource, while PATCH applies a partial update
    2. PUT is unsafe and PATCH is safe by definition
    3. PUT is only for creating resources, and PATCH is only for deleting them
    4. PUT works only with XML, while PATCH works only with JSON
    5. PUT requires a query string, while PATCH cannot include a body
  5. Property of repeated identical effects

    Sending the same DELETE /tasks/10 request multiple times results in the same final state on the server; what property is this an example of?

    1. Idempotence
    2. Impedance
    3. Immutability
    4. Throughput
    5. Idem-potents
  6. Status code for creation

    After successfully creating a new order with POST /orders, which HTTP status code should the server typically return?

    1. 201 Created
    2. 200 OK
    3. 202 Accepted
    4. 204 No Content
    5. 304 Not Modified
  7. Missing resource status

    If a client requests GET /users/9999 for a user that does not exist, which HTTP status code should be returned?

    1. 404 Not Found
    2. 401 Unauthorized
    3. 403 Forbidden
    4. 500 Internal Server Error
    5. 301 Moved Permanently
  8. Meaning of Content-Type

    In a POST request with a JSON body, what does the Content-Type: application/json header indicate?

    1. It declares the media type of the request body being sent
    2. It lists all formats the client can accept in the response
    3. It contains the unique identifier of the resource
    4. It prevents the response from being cached
    5. It sets the HTTP method to JSON
  9. REST statelessness

    Which statement best describes REST's statelessness in client-server communication?

    1. Each request must contain all information needed, and the server does not store client session state between requests
    2. The server keeps a session object in memory for every client to speed up requests
    3. Clients must maintain a single open TCP connection for all requests
    4. Requests must be processed strictly in the order they were sent
    5. All application state must be stored only in cookies by rule
  10. Designing URIs for related resources

    Which URI is the most RESTful way to retrieve the comments belonging to a post with ID 42?

    1. /posts/42/comments
    2. /getComments?post=42
    3. /comments/post/42/listAll
    4. /posts/comments/42
    5. /comments?id=42u0026type=poast