Test your knowledge of HTTP and REST basics, including essential status codes, idempotency, and pagination concepts. This quiz helps reinforce best practices and common usage in web APIs and client-server communication.
HTTP Status Codes
Which HTTP status code indicates that a request has succeeded and returned the requested resource, such as in a typical GET request?
- 404 Found
- 200 OK
- 301 Moved
- 500 Success
404 Error Meaning
When an API returns a 404 status code, what does it most commonly signify?
- The resource was not found
- The request timed out
- The content has moved
- The server is unavailable
Definition of Idempotency
In RESTful APIs, what does it mean for an HTTP method to be idempotent?
- It returns multiple responses
- It can only create new resources
- It always changes server state
- Multiple identical requests have the same effect as a single one
Safe Methods in HTTP
Which HTTP method is considered safe because it does not modify any resource on the server?
- DELETE
- PATCH
- GET
- POST
Use of 201 Created
When should an API respond with a 201 Created status code?
- When a resource cannot be found
- When a new resource has been successfully created
- When a request is forbidden
- When a resource is deleted
Pagination Purpose
What is the main purpose of implementing pagination in a REST API that lists items?
- Allow multiple users to modify the resource simultaneously
- Increase the security of the API
- Limit the amount of data returned in a single response
- Ensure data is encrypted during transfer
Pagination Parameters
Which two common query parameters are used to control pagination in an API endpoint?
- type and id
- page and limit
- sort and filter
- token and status
PUT vs POST Idempotency
Which HTTP method is typically idempotent when updating a resource, such as updating user data?
- PUT
- TRACE
- CONNECT
- POST
400 Bad Request
What does the 400 Bad Request status code indicate in an HTTP response?
- The server cannot process the request due to invalid input
- The authentication failed
- The request was redirected
- The resource already exists
DELETE Method Idempotency
If you send the same DELETE request multiple times to remove the same resource in a REST API, what is the expected behavior according to idempotency rules?
- A server error will occur after the first attempt
- Only the first request deletes the resource; subsequent ones do nothing
- Every request will fail after the first
- Each request will create a new resource