- 200 - success/OK
- 201 - CREATED - used in POST or PUT methods.
- 304 - NOT MODIFIED - used in conditional GET requests to reduce the bandwidth use of the network. Here, the body of the response sent should be empty.
- 400 - BAD REQUEST - This can be due to validation errors or missing input data.
- 401- UNAUTHORIZED - This is returned when there is no valid authentication credentials sent along with the request.
- 403 - FORBIDDEN - sent when the user does not have access (or is forbidden) to the resource.
- 404 - NOT FOUND - Resource method is not available.
- 500 - INTERNAL SERVER ERROR - server threw some exceptions while running the method.
- 502 - BAD GATEWAY - Server was not able to get the response from another upstream server.
REST API Interview Questions and Answers
Intermediate / 1 to 5 years experienced level questions & answers
Ques 1. Why is it simple to scale REST services?
Due to their statelessness, which prevents them from storing data from the server even since they are requested, REST services are scalable.
Ques 2. How big of a payload can you send using POST methods?
There isn't, theoretically, a cap on the size of the payload that can be transmitted via POST methods. Larger payloads, however, may require more bandwidth. As a result, processing the request by the server can take longer.
Ques 3. What does the REST API's caching do?
In order to quickly obtain a server answer in the future, REST API maintains a copy of the response in a specific region of computer memory. Catching is the term for this brief technique.
Ques 4. What distinguishes REST and SOAP from one another?
REST(Representational State Transfer):
- It is a web service development architectural design pattern.
- It is more cacheable and speedier in speed.
- It just takes on the protocol-specific security measures that have been put in place.
SOAP (Simple Object Access Protocol):
- It is a stringent protocol that is used to provide safe APIs.\
- It is not cacheable and moves more slowly.
- It can specify its own security precautions.
For more differences please check here: REST vs SOAP
Ques 5. What are a few REST's flaws?
Statelessness is an advantage of REST, but it can also be a drawback.
State is not preserved through REST. In those other words, the server doesn't save a history of previous communications. If maintaining state is required, the client is responsible for doing so.
Developers must exercise caution and only use APIs from reliable, authentic providers as REST has less stringent security controls than SOAP. REST is therefore a bad choice for transmitting private data among servers and clients.
Ques 6. Mention a few of REST's most important attributes.
REST has a number of important features, including
- Because REST is stateless, the SERVER has had no state or session data
- The server might be resumed in between calls thanks to a well-implemented REST API because all data is sent to the server.
- While REST uses GET to access services, web services often employ POST to carry out tasks.
Ques 7. What do Web API Media type formatters do?
The Web API's Media type formatter includes:
- The foundation class used to handle serializing and deserializing solid objects is called MediaTypeFormatter.
- BufferedMediaTypeFormatter is an utility class that enables asynchronous formatters on top of the infrastructure for asynchronous formatters.
Ques 8. Please tell most commonly used HTTP status codes.
Ques 9. How does HTTP Basic Authentication work?
While implementing Basic Authentication as part of APIs, the user must provide the username and password which is then concatenated by the browser in the form of “username: password” and then perform base64 encoding on it. The encoded value is then sent as the value for the “Authorization” header on every HTTP request from the browser. Since the credentials are only encoded, it is advised to use this form when requests are sent over HTTPS as they are not secure and can be intercepted by anyone if secure protocols are not used.
Most helpful rated by users:
- What is the REST stands for?
- What is REST API (RESTful Web Services)?
- RESTful web services, what exactly do you mean?
- What characteristics distinguish RESTful web services?
- What does messaging mean in the context of RESTful internet services?