REST API Interview Questions| Most Asked Questions For Interview

6555
REST API Interview Questions
REST API Interview Questions

REST API Interview Questions| Most Asked Questions For Interview

REST API Interview Questions Set 1

#1 What is REST Web Services?

REST is the acronym for REpresentational State Transfer. REST is an architectural style for developing applications that can be accessed over the network. REST architectural style was brought in light by Roy Fielding in his doctoral thesis in 2000.

REST is a stateless client-server architecture where web services are resources and can be identified by their URIs. Client applications can use HTTP GET/POST methods to invoke Restful web services. REST doesn’t specify any specific protocol to use, but in almost all cases it’s used over HTTP/HTTPS.

When compared to SOAP web services, these are lightweight and don’t follow any standard. We can use XML, JSON, text, or any other type of data for request and response.

#2 Explain what is REST and RESTFUL?

REST represents Representational State Transfer; it is a relatively new aspect of writing web API.

RESTFUL is referred for web services written by applying the REST architectural concept are called RESTful services, it focuses on system resources and how the state of the resource should be transported over HTTP protocol to different clients written in different languages. In RESTFUL web service HTTP methods like GET, POST, PUT, and DELETE can be used to perform CRUD operations.

#3 What are the advantages of REST web services? 

Some of the advantages of REST web services are:

  • The learning curve is easy since it works on the HTTP protocol
  • Supports multiple technologies for data transfer such as text, XML, JSON, image, etc.
  • No contract defined between server and client, so loosely coupled implementation.
  • REST is a lightweight protocol
  • REST methods can be tested easily over the browser.

#4 What is a Resource in Restful web services? 

The resource is the fundamental concept of Restful architecture. A resource is an object with:

  • a type,
  • relationship with other resources and
  • methods that operate on it.

Resources are identified with:

  • their URI,
  • HTTP methods they support and
  • request/response data type and format of data.

#5 Mention what are the HTTP methods supported by REST?

HTTP methods supported by REST are:

  • GET: It requests a resource at the request URL. It should not contain a request body as it will be discarded. Maybe it can be cached locally or on the server.
  • POST: It submits information to the service for processing; it should typically return the modified or new resource
  • PUT: At the request URL it updates the resource
  • DELETE: At the request URL it removes the resource
  • OPTIONS: It indicates which techniques are supported
  • HEAD: About the request URL it returns meta information

#6  Mention whether you can use GET request instead of PUT to create a resource?

No, you are not supposed to use PUT for GET. GET operations should only have view rights, while PUT resource is used for updating a data. This is an important REST API Interview Questions

#7 Mention what are resources in a REST architecture?

Resources are identified by logical URLs; it is the key element of a RESTful design. Unlike, SOAP web services in REST, you view the product data as a resource and this resource should contain all the required information.

#8 Mention what is the difference between AJAX and REST?

Ajax

  • In Ajax, the request is sent to the server by using XMLHttpRequest objects. The response is used by the JavaScript code to dynamically alter the current page
  • Ajax is a set of technology; it is a technique of dynamically updating parts of UI without having to reload the page
  • Ajax eliminates the interaction between the customer and server asynchronously

REST

  • REST requires the interaction between the customer and server
  • REST has a URL structure and a request/response pattern the revolve around the use of resources
  • REST is a type of software architecture and a method for users to request data or information from servers
  • REST requires the interaction between the customer and server

#9 Mention what is the difference between SOAP and REST?

SOAP

  1. SOAP is a protocol through which two computers communicates by sharing XML document
  2. SOAP permits the only XML
  3. SOAP-based reads cannot be cached
  4. SOAP is like a custom desktop application, closely connected to the server
  5. SOAP is slower than REST
  6. It runs on HTTP but envelopes the message

REST

  1. Rest is a service architecture and design for network-based software architectures
  2. REST supports many different data formats
  3. REST reads can be cached
  4. A REST client is more like a browser; it knows how to standardized methods and an application has to fit inside it
  5. REST is faster than SOAP
  6. It uses the HTTP headers to hold meta information

#10 What is the purpose of a URI in REST-based web services? 

URI stands for Uniform Resource Identifier. Each resource in a REST architecture is identified by its URI. The purpose of a URI is to locate a resource(s) on the server hosting the web service. This is an important REST API Interview Questions

A URI is of the following format:

<protocol>://<service-name>/<ResourceType>/<ResourceID>

#11 What is the difference between Monolithic, SOA, and Microservices Architecture?

  • Monolithic Architecture is similar to a big container wherein all the software components of an application are assembled together and tightly packaged.
  • Service-Oriented Architecture is a collection of services that communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity.
  • Microservice Architecture is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.

#12 Mention what is the difference between PUT and POST? 

PUT puts a file or resource at a particular URI and exactly at that URI. If there is already a file or resource at that URI, PUT changes that file or resource. If there is no resource or file there, PUT makes one

POST sends data to a particular URI and expects the resource at that URI to deal with the request. The web server at this point can decide what to do with the data in the context of a specified resource

PUT is idempotent meaning, invoking it any number of times will not have an impact on resources.

However, POST is not idempotent, meaning if you invoke POST multiple times it keeps creating more resources

REST API interview questions

#13 What is the purpose of the HTTP Status Code? 

HTTP Status code is standard code and refers to the predefined status of the task done at the server. For example, HTTP Status 404 states that the requested resource is not present on the server.

Consider the following status codes:

  • 200 – OK, shows success.
  • 201 – CREATED, when a resource is successfully created using POST or PUT request. Return link to a newly created resource using a location header.
  • 304 – NOT MODIFIED, used to reduce network bandwidth usage in case of conditional GET requests. The response body should be empty. Headers should have a date, location, etc.
  • 400 – BAD REQUEST, states that invalid input is provided e.g. validation error, missing data.
  • 401 – FORBIDDEN, states that user is not having access to the method being used, for example, delete access without admin rights.
  • 404 – NOT FOUND, states that the method is not available.
  • 409 – CONFLICT, states conflict situations while executing the method, for example, adding a duplicate entry.
  • 500 – INTERNAL SERVER ERROR, states that the server has thrown some exceptions while executing the method.

#14 What is caching?

Caching refers to storing server response in the client itself so that a client needs not to make server requests for the same resource again and again. A server response should have information about how a caching is to be done so that a client caches response for a period of time or never caches the server response.

#15 What is JAX-RS?

JAX-RS stands for JAVA API for RESTful Web Services. JAX-RS is a JAVA based programming language API and specification to provide support for created RESTful Webservices. Its 2.0 version was released on 24 May 2013. JAX-RS makes heavy use of annotations available from Java SE 5 to simplify the development of JAVA based web services creation and deployment. It also provides supports for creating clients for RESTful web services.

#16 List out the tools or API for developing or testing web API?

Testing tools for web services for REST APIs include

  • Spring REST web service using MVC
  • Jersey API
  • CXF
  • Axis
  • Restlet,

#17 What are the primary security issues of web service? 

To ensure reliable transactions and secure confidential information, web services require a very high level of security which can be only achieved through the Entrust Secure Transaction Platform. Security issues for web services are broadly divided into three sections as described below

1) Confidentiality: A single web service can have multiple applications and their service path contains a potential weak link at its nodes. Whenever messages or say XML requests are sent by the client along with the service path to the server, they must be encrypted. Thus, maintaining the confidentiality of communication is a must.

2) Authentication: Authentication is basically performed to verify the identity of the users as well as ensuring that the user using the web service has the right to use or not? Authentication is also done to track the user’s activity. There are several options that can be considered for this purpose

  • Application-level authentication
  • HTTP digest and HTTP basic authentication
  • Client certificates

3) Network Security: This is a serious issue that requires tools to filter web service traffic.

#18 Mention what is the difference between RPC or document style web services? How do you determine which one to choose?

In document style web services, we can transport an XML message as part of a SOAP request which is not possible in RPC style web service. Document style web service is most appropriate in some applications where XML message behaves as document and content of that document can alter and the intention of web service does not rely on the content of XML message.

#19 Mention what are the different application integration styles?

The different integration styles include

  • Shared database
  • Batch file transfer
  • Invoking remote procedure(RPC)
  • Swapping asynchronous messages over a message-oriented middleware (MOM)

#20What are the disadvantages of REST web services?

Some of the disadvantages of REST are:

  • Since there is no contract defined between service and client, it has to be communicated through other means such as documentation or emails.
  • Since it works on HTTP, there can’t be asynchronous calls.
  • Sessions can’t be maintained.

If You Want To Get More Daily Such Jobs Updates, Career Advice Then Join the Telegram Group From Given Link And Never Miss Update.

Join Telegram Group of Daily Jobs Updates for 2010-2021 Batch: Click Here

Why You’re Not Getting Response From Recruiter?: Click here

How To Get a Job Easily: Professional Advice For Job Seekers: Click here

Cognizant Latest News: Up To 20K+ Employees Will Be Hired: Click here

COVID-19 Live Tracker India & Coronavirus Live Update: Click here

Why Remove China Apps took down from Play store?: Click here

Feel Like Demotivated? Check Out our Motivation For You: Click here

List of Best Sites To Watch Free Movies Online in 2020: Click here

5 Proven Tips For How To Look Beautiful and Attractive: Click here