Rest Api Interview Questions
Rest Api Interview Questions
1. What is REST?
Answer: REST stands for Representational State Transfer, and is an architectural style based
on the Hypertext Transfer Protocol (HTTP) for developing web-based applications.
REST outlines several guidelines that web services must follow to be considered RESTful.
These guidelines ensure that requests and resources are sent easily and efficiently between
client and server using standardized HTTP methods.
6. Which markup languages are primarily used to represent resources in REST APIs?
Answer: In REST APIs, XML (extensible markup language) and JSON (JavaScript Object
Notation) are the two most common languages for representing resources.
8. What is the difference between the POST method and the PUT method?
Answer: POST and PUT are similar, but not exactly the same. POST is for creating a
resource on the server, whereas PUT is for replacing a resource at a specific URI with another
resource. If you use PUT at a URI that already has an associated resource, PUT will replace
that resource. If there is no resource at the specified URI, PUT creates one.
Additionally, PUT is idempotent, which means that calling it multiple times will only result
in one resource. This is because each call replaces the existing resource (or creates a new one
if there is nothing to replace).
POST is not idempotent. If you call POST 10 times, you’ll end up with 10 different resources
on the server, each with its own URI. This also means that POST responses are cacheable,
whereas PUT responses are not.
9. What is CRUD?
Answer: CRUD stands for “Create, Read, Update, Delete.” These are the four basic actions
that can be performed on databases through a REST API. Each action corresponds to an
HTTP request method:
Create = POST
Read = GET
Update = PUT
Delete = DELETE
It’s not the most elegant of acronyms, but it works.
13. What are some common HTTP response status codes you might see when working
with a REST API?
Answer: HTTP response status codes tell the client the result of the requested action (GET,
POST, etc.). Some common codes you’ll see in HTTP responses are:
200 OK: The request succeeded.
201 Created: The request succeeded and a resource was created.
400 Bad Request: The request was not fulfilled due to an error in the request, such as a typo
or missing data.
401 Unauthorized: The request was not fulfilled because the client is not authenticated or
authorized to access the requested resource.
403 Forbidden: The request was not fulfilled because the client is authenticated, but not
authorized to access the requested resource.
404 Not Found: The request was not fulfilled because the server could not locate the
requested resource.
500 Internal Server Error: The request was not fulfilled due to an unexpected problem with
the server. (See also: 500 Internal Server Errors: What They Are & How to Fix Them)
502 Bad Gateway: The request was not fulfilled due to an invalid response from an upstream
server.
503 Service Unavailable: The server was unable to process the request due to maintenance,
overloading, or another temporary interference.