Meaning of REST and resources
What does REST stand for, and what is a 'resource' in this context?
- Representational State Transfer; a resource is any addressable piece of information such as a user, order, or image
- Remote Execution State Transfer; a resource is only a row in a database table
- Representational Stateless Transport; a resource is only a static file
- Resource Exchange over State Transfer; a resource is the physical server machine
- Relational State Transmission; a resource is just an IP address
Correct method to read data
Which HTTP method should you use to retrieve data without changing it, for example GET /products?category=books?
- GET
- POST
- PUT
- PATCH
- DELETE
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?
- POST
- GET
- DELETE
- CONNECT
- POTS
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?
- PUT typically replaces the entire resource, while PATCH applies a partial update
- PUT is unsafe and PATCH is safe by definition
- PUT is only for creating resources, and PATCH is only for deleting them
- PUT works only with XML, while PATCH works only with JSON
- PUT requires a query string, while PATCH cannot include a body
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?
- Idempotence
- Impedance
- Immutability
- Throughput
- Idem-potents
Status code for creation
After successfully creating a new order with POST /orders, which HTTP status code should the server typically return?
- 201 Created
- 200 OK
- 202 Accepted
- 204 No Content
- 304 Not Modified
Missing resource status
If a client requests GET /users/9999 for a user that does not exist, which HTTP status code should be returned?
- 404 Not Found
- 401 Unauthorized
- 403 Forbidden
- 500 Internal Server Error
- 301 Moved Permanently
Meaning of Content-Type
In a POST request with a JSON body, what does the Content-Type: application/json header indicate?
- It declares the media type of the request body being sent
- It lists all formats the client can accept in the response
- It contains the unique identifier of the resource
- It prevents the response from being cached
- It sets the HTTP method to JSON
REST statelessness
Which statement best describes REST's statelessness in client-server communication?
- Each request must contain all information needed, and the server does not store client session state between requests
- The server keeps a session object in memory for every client to speed up requests
- Clients must maintain a single open TCP connection for all requests
- Requests must be processed strictly in the order they were sent
- All application state must be stored only in cookies by rule
Designing URIs for related resources
Which URI is the most RESTful way to retrieve the comments belonging to a post with ID 42?
- /posts/42/comments
- /getComments?post=42
- /comments/post/42/listAll
- /posts/comments/42
- /comments?id=42u0026type=poast