REST API Interview Questions and Answers

RESTful Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Exams like Academic, Certification and Job Interviews. This section provides a useful collection of sample Interview Questions and their answers with appropriate explanations.

It is important for any developer to know what REST is, how it works, what are its features and how can you develop services in a secure manner to go with the trend. Many companies prefer developers with REST knowledge as they can help them develop products that are scalable, easy to maintain and make their products reach out to the world due to the power of the internet. In the below section, we will see what are the most commonly asked questions on RESTful web services during an interview.

1. What are webservices?
A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer.

2. How does a web service work?
A web service is used to communicate among various applications by using open standards such as HTML, XML, WSDL, and SOAP. You can build a Java-based web service on Solaris that is accessible from your Visual Basic program that runs on Windows. You can also use C# to develop new web services on Windows invokes from your web application that is based on Java Server Pages (JSP) and runs on Linux. Not only this you can use most of the programming languages.


3. What are the advantages of web services?
These are some of the important advantages of web services:
o Interoperability: With the help of web services, an application can communicate with other application developed in any language.
o Reusability: We can expose the web service so that other applications can use it.
o Modularity: With the help of web service, we can create a service for a specific task such as tax calculation.
o A Standard protocol for every application program: Web services use standard protocol so that all the client applications written in different languages can understand it. This Standard protocol helps in achieving cross-platform.
o Cheaper cost for communication: Web services uses SOAP over HTTP so that anybody can use existing internet for using web services.

4. What are the different types of web services?
There are two types of web services:
o SOAP – It is an XML-based protocol for accessing web services.
o RESTful – It is an architectural style, not a protocol.


5. What is SOAP?
SOAP stands for Simple Object Access Protocol. SOAP is an XML based industry standard protocol for designing and developing web services.

6. What is WSDL?
WSDL stands for Web Service Description Language. WSDL is an XML based document that provides technical details about the web service. Some of the useful information in WSDL document are:
method name,
o port types,
o service end point,
o binding,
o method parameters etc.

7. What are the main features of web services?
Following is a list of main features of web services:
o It is available over the Internet or private (intranet) networks.
o It uses a standardized XML messaging system.
o It is not tied to any one operating system or programming language.
o It is self-describing via a common XML grammar.
o It is discoverable via a simple find mechanism.

8. What is an API?
An API is an interface that allows users to interact with a program through a client. A client can be a browser that an end-user uses to access a website. For example, when you use your browser to access any website, you’re interacting with that specific website’s API through the browser.
A client can also be another application. If you’re a software developer, you might write a program that accesses the website API to pull in information about different things through the client application. Either way, the client provides access to the API and its resources which are the objects that the application stores information about.

9. What do you understand by RESTful Web Services?
RESTful web services are services that follow REST architecture. REST stands for Representational State Transfer and uses HTTP protocol (web protocol) for implementation. These services are lightweight, provide maintainability, scalability, support communication among multiple applications that are developed using different programming languages. They provide means of accessing resources present at server required for the client via the web browser by means of request headers, request body, response body, status codes, etc.

10. 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 REST architectural concept are called RESTful services, it focuses on system resources and how state of resource should be transported over HTTP protocol to different clients written in different language. In RESTFUL web service HTTP methods like GET, POST, PUT and DELETE can be used to perform CRUD operations.

11. When we will call a web service a RESTFUL service?
REST architecture presents a set of constraints/guiding principles to be used in the creation of web services. The services that use REST constraints are called as RESTful Web Services. To be referred to as RESTful, it should satisfy the six-guiding constraints. These constraints are names as the client-server, stateless, cacheable, uniform interface, layered system, and code on demand.

12. What are the primary security issues of web service?
To ensure reliable transactions and secure confidential information, web services requires very high level of security which can be only achieved through 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 the 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 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 which requires tools to filter web service traffic.

13. What is addressing in RESTfulwebservices?
Addressing refers to locating a resource or multiple resources lying on the server. It is analogous to locate a postal address of a person.

14. Explain the architectural style for creating web API?
The architectural style for creating web api are
• HTTP for client server communication
• XML/JSON as formatting language
• Simple URI as the address for the services
• Stateless communication

15. What is a REST Resource?
Every content in the REST architecture is considered a resource. The resource is analogous to the object in the object-oriented programming world. They can either be represented as text files, HTML pages, images, or any other dynamic data.
• The REST Server provides access to these resources whereas the REST client consumes (accesses and modifies) these resources. Every resource is identified globally by means of a URI.

16. How to represent a resource in REST?
REST uses various representations to represent a resource where text, JSON, XML. XML and JSON are the most popular representations of resources.

17. What are the best practices to design a resource representation?
Following are important points to be considered while designing a representation format of a resource in a RESTful web services –
• Understandability – Both Server and Client should be able to understand and utilize the representation format of the resource.
• Completeness – Format should be able to represent a resource completely. For example, a resource can contain another resource. Format should be able to represent simple as well as complex structures of resources.
• Linkablity – A resource can have a linkage to another resource, a format should be able to handles such situations.

18. Why proper representation of Resource is required?
Representation is very important because it determines the easy identification of resources. With proper representations of resource in the proper format, allows the client to easily understand the format.

19. Enlist some important points that should be kept in mind while designing Resources representation for RESTful web services.
As there are no restrictions on the format in which the resource representation is done but just that the main requirement is the format of the representation should be as per the client requirement.
A good resource representation is designed by considering the following main points:
• The resource representation format should be easily understood by the client and server.
• The representation should be complete regardless of its format structure, which may be complex or simple.
• In the case of the link of the resources to other resources, such cases should also be considered and handled.

20. 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.

21. What is Restletframework ?
Restlet is leading RESTful web framework for Java applications is used to build RESTFul web services it has two part Restlet API and a Restlet implementation much like Servlet specification. There are many implementation of Restlet framework available you just need to add there jar in your classpath to use them. By using Restlet web framework you can write client and server.

22. Can you use Restlet without any web-container ?
Yes, Restletframework provide default server which can be used to handle service request in web container is not available.

23. What is RESTEasy ?
RESTEasy is another REST framework introduced in JBoss Application Server. This was rather easy REST interview questions. you can answer in detail only if you have used this or working in JBoss.

24. Mention some key characteristics of REST?
Some key characteristics of REST includes
• REST is stateless, therefore the SERVER has no state (or session data)
• With a well-applied REST API, the server could be restarted between two calls as every data is passed to the server
• Web service mostly uses POST method to make operations, whereas REST uses GET to access resources

25. Which protocol is used by RESTfulwebservices?
RESTful web services make use of HTTP protocol as a medium of communication between client and server.

26. How to display custom error pages using RestFull web services ?
In order to customize error you need to extend StatusService and implement getRepresentation(Status, Request, Response) method with your custom code now assign instance of your CustomStatusService to appropriate “statusService property”.

27. What is the difference between the top-down and bottom-up approaches of developing web services?
In the top-down approach first WSDL document is created and then Java classes are developed based on the WSDL contract, so if the WSDL contract changes you got to change your Java classes while in the case of the bottom-up approach of web service development you first create Java code and then use annotations like @WebService to specify contract or interface and WSDL field will be automatically generated from your build.

28. What happens if RestFull resources are accessed by multiple clients? do you need to make it thread-safe?
Since a new Resource instance is created for every incoming Request there is no need to make it thread-safe or add synchronization. multiple clients can safely access RestFull resources concurrently.

29. Explain messaging technique.
Messages are the mode of exchanging data for any type of communication to take place. In the same way, HTTP protocol plays the role of message communication between the client and server through HTTP Request and Response methods. HTTP request is sent by the client who contains information about the data and in turn, receives HTTP Response from the server.
Messages are the collection of information about the data i.e. Metadata.

30. What is URI?
Uniform Resource Identifier is the full form of URI which is used for identifying each resource of the REST architecture. URI is of the format:



There are 2 types of URI:
URN: Uniform Resource Name identifies the resource by means of a name that is both unique and persistent.
o URN doesn’t always specify where to locate the resource on the internet. They are used as templates that are used by other parsers to identify the resource.
o These follow the urn scheme and usually prefixed with urn:. Examples include
? urn:isbn:1234567890 is used for identification of book based on the ISBN number in a library application.
? urn:mpeg:mpeg7:schema:2001 is the default namespace rules for metadata of MPEG-7 video.
o Whenever a URN identifies a document, they are easily translated into a URL by using “resolver” after which the document can be downloaded.

URL: Uniform Resource Locator has the information regarding fetching of a resource from its location.
o Examples include:

o URLs start with a protocol (like ftp, http etc) and they have the information of the network hostname ( and the path to the document(/samplePage.html). It can also have query parameters.

31. What is purpose of a URI in REST based webservices?
Purpose of an URI is to locate a resource(s) on the server hosting the web service.

32. What is format of a URI in REST architecture?
A URI is of following format –


33. What are the features of RESTful Web Services?
Every RESTful web service has the following features:
• The service is based on the Client-Server model.
• The service uses HTTP Protocol for fetching data/resources, query execution, or any other functions.
• The medium of communication between the client and server is called “Messaging”.
• Resources are accessible to the service by means of URIs.
• It follows the statelessness concept where the client request and response are not dependent on others and thereby provides total assurance of getting the required data.
• These services also use the concept of caching to minimize the server calls for the same type of repeated requests.
• These services can also use SOAP services as implementation protocol to REST architectural pattern.

34. What is the concept of statelessness in REST?
The REST architecture is designed in such a way that the client state is not maintained on the server. This is known as statelessness. The context is provided by the client to the server using which the server processes the client’s request. The session on the server is identified by the session identifier sent by the client.


35. What are the advantages of statelessness in RESTfulWebservices?
Following are the benefits of statelessness in RESTful web services –
• Web services can treat each method request independently.
• Web services need not to maintain client’s previous interactions. It simplifies application design.
• As HTTP is itself a statelessness protocol, RESTful Web services work seamlessly with HTTP protocol.

36. What are the disadvantages of statelessness in RESTfulWebservices?
Following is the disadvantage of statelessness in RESTful web services –
Web services need to get extra information in each request and then interpret to get the client’s state in case client interactions are to be taken care of.

37. Enlist some important constraints for RESTful web services.
Every constraint has positive as well as negative impacts and to produce an overall architecture, there should be a balance between both of them.
Below mentioned are some important constraints for RESTful web service:
• There should be separate concerns for each server and client which will help to maintain the modularity within the application. This will also reduce the complexity and increase the scalability.
• The client-server communication should be stateless, which means no previous information is used and the complete execution is done in isolation. In cases of failure, it also helps the client to recover.
• In client-server communication, the HTTP response should be cacheable so that when required cached copy can be used which in turn enhances the scalability and performance of the server.
• The fourth constraint is the uniform interface which allows client-server interaction to be easily understood. This constraint is further divided into four sub-constraints as:
• Resource Identification
• Resource Manipulation
• Each message is easily understood and is self-descriptive.
• Hypermedia, which is defined as the text with hyperlinks and when clicked, it moves to another application state.
• Client-server communication should be done on a layered system and thus the client should only have knowledge about the intermediate level with which communication is being done,

38. 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 middle-ware (MOM)

39. Explain how JAXB related to RESTful web API?
JAXB stands for java arch for XML binding.

40. What do you understand by JAX-RS?
As the name itself stands (JAX-RS= Java API for RESTful Web Services) is a Java-based specification defined by JEE for the implementation of RESTful services. The JAX-RS library makes usage of annotations from Java 5 onwards to simplify the process of web services development. The latest version is 3.0 which was released in June 2020. This specification also provides necessary support to create REST clients.

41. What are HTTP Status codes?
These are the standard codes that refer to the predefined status of the task at the server. Following are the status codes formats available:
• 1xx – represents informational responses
• 2xx – represents successful responses
• 3xx – represents redirects
• 4xx – represents client errors
• 5xx – represents server errors
Most commonly used status codes are:
• 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 – 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.

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

43. What HTTP Status Code 409 states?
It means, CONFLICT, states conflict situation while executing the method for example, adding duplicate entry.

44. What are the HTTP Methods?
HTTP Methods are also known as HTTP Verbs. They form a major portion of uniform interface restriction followed by the REST that specifies what action has to be followed to get the requested resource. Below are some examples of HTTP Methods:
• GET: This is used for fetching details from the server and is basically a read-only operation.
• POST: This method is used for the creation of new resources on the server.
• PUT: This method is used to update the old/existing resource on the server or to replace the resource.
• DELETE: This method is used to delete the resource on the server.
• PATCH: This is used for modifying the resource on the server.
• OPTIONS: This fetches the list of supported options of resources present on the server.

The POST, GET, PUT, DELETE corresponds to the create, read, update, delete operations which are most commonly called CRUD Operations.


GET, HEAD, OPTIONS are safe and idempotent methods whereas PUT and DELETE methods are only idempotent. POST and PATCH methods are neither safe nor idempotent.

45. What do you mean by idempotent operation?
Idempotent operations means their result will always same no matter how many times these operations are invoked.

46. Which type of Webservices methods are to be idempotent?
PUT and DELETE operations are idempotent.

47. Which type of Webservices methods are to be read only?
GET operations are read only and are safe.

48. What should be the purpose of OPTIONS method of RESTful web services?
It should list down the supported operations in a web service and should be read only.

49. What should be the purpose of HEAD method of RESTful web services?
It should return only HTTP Header, no Body and should be read only.

50. Can you use GET instead of PUT to create a new resource, why or why not?
No, you cannot use the GET feature instead of PUT, because GET has view-rights only.

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + = seventeen

Popup Dialog Box Powered By :
  • RSS
  • Facebook
  • Google+
  • Twitter