Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

REST API Interview Questions and Answers

Related differences

GraphQL vs RESTful Web Services (REST API)RESTful Web Services (REST API) vs gRPC

Ques 46. What constitutes the core components of HTTP Response?

HTTP Response has 4 components:

  • Response Status Code − This represents the server response status code for the requested resource. Example- 400 represents a client-side error, 200 represents a successful response.
  • HTTP Version − Indicates the HTTP protocol version.
  • Response Header − This part has the metadata of the response message. Data can describe what is the content length, content type, response date, what is server type, etc.
  • Response Body − This part contains what is the actual resource/message returned from the server.

Is it helpful? Add Comment View Comments
 

Ques 47. Define Addressing in terms of RESTful Web Services.

Addressing is the process of locating a single/multiple resources that are present on the server. This task is accomplished by making use of URI (Uniform Resource Identifier). The general format of URI is:

<protocol>://<application-name>/<type-of-resource>/<id-of-resource>

Is it helpful? Add Comment View Comments
 

Ques 48. What are the differences between PUT and POST in REST?

PUTPOST
PUT methods are used to request the server to store the enclosed entity in request. In case, the request does not exist, then new resource has to be created. If the resource exists, then the resource should get updated.POST method is used to request the server to store the enclosed entity in the request as a new resource.
The URI should have a resource identifier. Example: PUT /users/{user-id}The POST URI should indicate the collection of the resource. Example: POST /users
PUT methods are idempotent.POST methods are not idempotent.
PUT is used when the client wants to modify a single resource that is part of the collection. If a part of the resource has to be updated, then PATCH needs to be used.POST methods are used to add a new resource to the collection.
The responses are not cached here despite the idempotency.Responses are not cacheable unless the response explicitly specifies Cache-Control fields in the header.
In general, PUT is used for UPDATE operations.POST is used for CREATE operations.

Is it helpful? Add Comment View Comments
 

Ques 49. What is difference between REST and Web Socket?

RESTWeb Socket
REST follows stateless architecture, meaning it won’t store any session-based data.Web Socket APIs follow the stateful protocol as it necessitates session-based data storage.
The mode of communication is uni-directional. At a time, only the server or the client will communicate.The communication is bi-directional, communication can be done by both client or server at a time.
REST is based on the Request-Response Model.Web Socket follows the full-duplex model.
Every request will have sections like header, title, body, URL, etc.Web sockets do not have any overhead and hence suited for real-time communication.
For every HTTP request, a new TCP connection is set up.There will be only one TCP connection and then the client and server can start communicating.
REST web services support both vertical and horizontal scaling.Web socket-based services only support vertical scaling.
REST depends on HTTP methods to get the response.Web Sockets depend on the IP address and port number of the system to get a response.
Communication is slower here.Message transmission happens very faster than REST API.
Memory/Buffers are not needed to store data here.Memory is required to store data.

Is it helpful? Add Comment View Comments
 

Ques 50. Can we implement transport layer security (TLS) in REST?

Yes, we can. TLS does the task of encrypting the communication between the REST client and the server and provides the means to authenticate the server to the client. It is used for secure communication as it is the successor of the Secure Socket Layer (SSL).

HTTPS works well with both TLS and SSL thereby making it effective while implementing RESTful web services. One point to mention here is, the REST inherits the property of the protocol it implements. So security measures are dependent on the protocol REST implements.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook