REST Interview Questions & Answers- Part 3
As a full stack developer, your ability to build and integrate REST APIs is crucial to delivering seamless user experiences. REST APIs connect the frontend with the backend, allowing data to move efficiently between systems. Interviewers often test your ability to consume APIs on the client side and create them on the server side.
This guide features key REST API interview questions and answers that reflect real-world scenarios. Topics include HTTP methods, status codes, request headers, middleware, and error handling. You’ll also learn how to discuss CORS, token-based authentication, and API versioning—essential concepts in modern web apps.
Whether you use React with Express.js or Angular with Django, these questions will sharpen your understanding of REST and improve your technical communication. Use this guide to get fully prepared and ready to speak confidently about REST APIs in your next full-stack interview.
Answer:
A Restful system comprises of:
- The server has the resources.
- The client who requests for the resources.
It is essential to create REST API as per the industry standards, which increases client adoption & ease of development. There are 6 architectural constraints as follows:
- Stateless
- Cacheable
- Uniform Interface
- Client-Server
- Layered System
- Code on Demand
Answer:
‘Resource’ is an object which can be an HTML file, image, or any type of dynamic data. There are various representation formats available to represent a resource; some of them are listed below:
- YAML
- XML
- JSON
- HTML
Answer:
A Cache-control header can help in obtaining cache ability. Below are some cache-control headers:
- Public:Resources marked as the public can be cached through any intermediate components between the server and the client.
- Private:A client can only cache the resources marked as private.
- No cache means that the resource cannot be cached; thus, the entire process is put to a halt.
Answer:
A payload in API is a data pack sent with the GET method in HTTP. It is the crucial information you submit to the server when making an API request. The payload can be received or sent in various formats, including JSON. The payload is usually denoted by a query string “{}.”
Answer:
JAX-RS is a Java API for RESTful web service. Amongst multiple frameworks & libraries, it is considered the most suitable Java-based API that supports RESTful web service. Some implementations of JAX-RS are:
- RESTEasy
- Apache CFX
- Jersey
- Play
Amongst the above, Jersey is the most popular framework.
Answer:
HTTP status codes are classified into 5 “classes” that have related or similar meanings. The five classes & their meaning include:
- 100s: These are informational codes denoting that a request initiated by a browser is continuing.
- 200s: These are success codes returned when the server processes, understand or receive a browser request.
- 300s: These are redirection codes returned when a new resource has been substituted for a requested resource.
- 400s: These are client error codes that represent a problem with the request.
- 500s: These are server error codes that indicate the request was accepted, but an error on the server prevented the request’s fulfillment.
Answer:
Here are the different WSDL components:
- xsd:import namespace & schemaLocation: It provides unique namespace & WSDL URL for web service.
- message: It defines data elements of every operation & used for method arguments.
- part: it is used for method argument type & name.
- port type: service name, there can be multiple services in a WSDL document.
- operation: It contains a method name.
- soap: It addresses the endpoint URL.
Answer:
Resource means a fundamental concept of Restful architecture. A resource is the object with a type & method that operates on it. Resources are identified from:
- HTTP methods
- Format of data
- URIs
- And request/response data type
Answer:
- Accept headers tells a web service of what kind of response client is accepting, so if a web service is capable of sending response in XML & JSON format and client sends Accept header as application/xml then XML response will be sent. For Accept header application/json, server will send the JSON response.
- Content-Type header is used to tell server what is the format of data being sent in the request. If Content-Type header is application/xml then server will try to parse it as XML data. This header is useful in HTTP Post and Put requests.
Answer:
When choosing between SOAP & REST, it all depends on project requirements. Have a look at some conditions that can affect your choice:
- If you already know web services, you can define a contract before implementation & SOAP seems a better choice. However, if you don’t have much knowledge, REST seems a better choice as you can provide sample request/response & test cases easily for client apps to use later.
- REST is the best choice for quick implementation. You can easily create web services & test them through browser/curl, and be prepared for the clients.
- If XML data type is supported, you should go with SOAP, but if you think about supporting JSON in the future also, then go with REST.
Answer:
Java API for XML Web Services is a technology for building web services & clients that communicate using XML. It enables developers to write remote procedure message-oriented & call-oriented web services. In JAX-WS, a web service operation invocation is represented by an XML-based protocol, like SOAP. The SOAP specification defines the encoding rules, envelope structure, & conventions for representing web service invocations & responses. These calls & responses are transmitted as SOAP messages (XML files) over HTTP.
Answer:
The sun-jaxws.xml is a file present in SOAP web services & helps in offering the details of the endpoints when JAX-WS web services get deployed in a servlet container. It is placed in the WEB-INF directory; the sun-jaxws.xml file contains meta-information, implementation class, URL pattern & endpoint name.
Answer:
JAX-RS or JAVA API for RESTful Web Services is a Java-based API & specification to provide support for creating RESTful Web Services. JAX-RS API uses annotations available from the Java SE 5 to simplify the development of Java-based web services. It also supports clients’ creation for RESTful Web Services.
Answer:
Wsimport utility refers to a command-line tool provided by JAX-WS. It generates all web services artifacts & includes web service client support code responsible for including URL in the client supporting class & qualified name.
Answer:
@XmlRootElement is used with JAXB (JSR-222); its purpose is to uniquely associate a root element with the class. As JAXB classes map to complex types, it enables a class to correspond to multiple root elements.
Answer:
To secure confidential information & ensure reliable transactions, web services need a very high level of security that can only be achieved through Entrust Secure Transaction Platform. Security issues for web services are mainly classified into three sections as below:
- Confidentiality: A single web service can have different applications & their service path contains a potential weak link at its nodes. When a client sends messages or XML requests along with the service path to the server, they must be encrypted. Thus, maintaining the confidentiality of communication is a must.
- Authentication: Authentication is performed to verify the users’ identity. Authentication helps to track a user’s activity. There are various options for this purpose like:
- Client certificates
- Application-level authentication
- HTTP digest and HTTP basic authentication
- Network Security: It is a serious issue that requires tools for filtering web service traffic.
Answer:
REST API deploys HTTP methods to perform operations. Some HTTP operations which don’t modify a resource at the server are called safe operations, e.g., HEAD & GET. On the other hand, POST, PUT, and DELETE is unsafe REST operations as they modify the resource on the server.
Answer:
Yes, REST is both interoperable & scalable. It doesn’t mandate a particular choice of technology either at the server or client end. You can use C++, Java, JavaScript, or Python to create RESTful Web Services & consume them at the client end.
Answer:
RestTemplate implements a synchronous HTTP client that enforces RESTful principles or simplifies sending requests:
- It provides a higher-level API to perform HTTP requests as compared to the traditional HTTP client libraries.
- It supports & automatically encodes URI templates.
- It supports automatic detection of the content type.
- It supports automatic conversion between HTTP messages & objects.
- It allows easy customization of the response errors. A custom ResponseErrorHandler can be registered on a RestTemplate.
- It provides methods for conveniently sending common HTTP request types and methods that allow for increased detail when sending requests.
Answer:
Much like how we require a postal address with a postal code to locate a person, ‘Addressing’ in RESTful web services is the process of locating resources hosted on a server. This is typically accomplished using a URI (Unified Resource Identifier).