Last Updated On
Are you familiar with REST APIs and want to test your understanding? This post contains 25 useful REST API multiple-choice questions (quiz) to self-test your knowledge of REST API development.
1. What does the Acronym REST Stand for?
Select the best answer
- Representational State Transform
- Representational State Transfer
- Represent State Transform
- Represent State Transfer
2. What is the protocol used in REST?
Choose one option
- FTP
- HTTP
- JMX
- SOAP
3. Which of the following component of HTTP request contains metadata for the HTTP Request message as key-value pairs?
Choose one option
- URI
- VERB
- HTTP Version
- Request Header
4. Which of the following is correct about URI in RESTful web services?
Choose one option
- Each resource in REST architecture is identified by its URI.
- Purpose of an URI is to locate a resource(s) on the server hosting the web service.
- Both (1) and (2)
- None of the above
5. What is the HTTP Status Code Related to Page Not Found?
Choose one option
- 402
- 404
- 403
- 401
6. What is the HTTP Code Related to Internal Server Error?
- 500
- 501
- 504
- 502
7. What does HTTP Code 200 indicate?
- Error
- Completed
- Success
- Warning
8. Which of the following is not an HTTP method?
Choose one option
- CREATE
- POST
- PUT
- OPTION
9. Which HTTP method do we use to make an HTTP request to create a new resource?
Choose one option
- POST
- PUT
- GET
- CREATE
10. Which HTTP method do we use to make an HTTP request to update an existing resource?
Choose one option
- POST
- PUT
- UPDATE
- DELETE
11. Choose the correct URI format to get a sub-resource by resource id and sub-resource id
Choose one options
- /{resource}/{resource-id}/{sub-resource}/{sub-resource-id}
- /{resource}/{sub-resource}/{sub-resource-id}
- {sub-resource}/{sub-resource-id}/{resource}/{resource-id}
- /{resource}/{resource-id}/{sub-resource-id}/{sub-resource}
12. What does the HTTP status code 201 indicate?
Choose one option
- OK
- Created
- Accepted
- No Content
13. Which HTTP methods are commonly used in REST API operations?
Choose one option
- GET, POST, PUT, DELETE
- CREATE, READ, UPDATE, DELETE
- INSERT, SELECT, UPDATE, DELETE
- SEND, RECEIVE, MODIFY, DELETE
14. Which of the following HTTP method should be used to delete resource using RESTful web service?
Choose one option
- GET
- DELETE
- POST
- OPTIONS
15. What is the recommended method and URL pattern for retrieving a specific user?
Choose one option
- GET /users/{id}
- GET /user/{id}
- GET /user?id={id}
- GET /users?id={id}
16. Which of the following HTTP Status code means FORBIDDEN, states that user is not having access to method being used for example, delete access without admin rights?
Choose one option
- 403
- 404
- 406
- 409
17. What does the status code 302 represent?
Choose one option
- Not Modified
- User can select among multiple links and go to different page.
- The resource requested has been found and moved temporarily to new URL location.
- The page requested is available only by means of proxy address given in the response.
18. What category do 1xx HTTP status codes belong to?
Choose one option
- Redirection
- Client Error
- Server Error
- Informational
19. What is the difference between PUT and PATCH methods in REST API?
- PUT is used for creating resources, while PATCH is used for updating resources
- PUT updates the entire resource, while PATCH updates only specific fields of a resource
- PUT requires authentication, while PATCH does not
- PUT is idempotent, while PATCH is not
20. What is the role of the “Content-Type” header in a REST API request?
Choose one option
- It specifies the HTTP method to be used
- It defines the format of the request payload
- It provides authentication credentials
- It determines the cache control policy for the request
21. What is the purpose of the “Authorization” header in a REST API request?
Choose one option
- It specifies the format of the request payload
- It provides additional metadata about the request
- It provides authentication credentials for accessing protected resources
- It determines the cache control policy for the request
22. In REST API design, what is idempotency?
Choose one option
- The ability of an API to handle multiple requests in parallel
- The property that a method can be called multiple times without different outcomes
- The capability of an API to update data
- The feature of an API that allows it to delete resources
23. What is the primary purpose of the HTTP OPTIONS method in REST APIs?
Choose one option
- To update a resource
- To retrieve the communication options available on a resource or server
- To delete a resource
- To create a resource
24. Which is a common command-line tool for using or exploring an API?
Choose one option
- ssh
- bash
- curl
- powerShell
25. Which of the following directive of Cache Control Header of HTTP response indicates that resource is not cachable?
Choose all options
- Public
- Private
- max-age
- no-cache/no-store
====================================================================
Answers
1) 2) Representational State Transfer
2) 2) HTTP
3) 4) Request Header
4) 3) Both (1) and (2)
5) 2) 404
6) 1) 500
7) 3) Success
8) 1) CREATE
9) 1) POST
10) 2) PUT
11) 1) /{resource}/{resource-id}/{sub-resource}/{sub-resource-id}
12) 2) Created
13) 1) GET, POST, PUT, DELETE
14) 2) DELETE
15) 1) GET /users/{id}
16) 1) 403
17) 3) The resource requested has been found and moved temporarily to new URL location.
18) 4) Informational
19) 2) PUT updates the entire resource, while PATCH updates only specific fields of a resource
20) 2) It defines the format of the request payload
21) 3) It provides authentication credentials for accessing protected resources
22) 2) The property that a method can be called multiple times without different outcomes
23) 2) To retrieve the communication options available on a resource or server
24) 3) curl
25) 4) no-cache/no-store