Learn these top REST API Services questions for freshers and experienced persons. These are all commonly asked in technical interviews and make you understand clearly.
1. What is RESTFul Services?
Transforming the Resources within or outside the application over HTTP Protocol.
RESTFul is a service accessed over the HTTP Network. It is a stateless service accessed and identified through the URIs.
2. Advantage of REST API?
- – Statelessness, The Services don’t need to worry about the client session management. As far as the request is received properly with relevant information, the request will get processed and sent back.
- – Easy to integrate with any kind of internal/ external applications over browser.
- – Lightweight
3. what is JAX-RS in Rest API?
– JAX-RS is a Java-based API that provides supports to the REST Annotations for the API and simplifies the development of the services.
4. What are all the Service status codes?
- 1XX – Informal Response
- 2XX – Success Response
- 3XX – Redirects
- 4XX – Client Errors
- 5XX – Server Errors
5. What are all the HTTP Methods used in REST?
- GET – Fetching the details from the server, is a read operation
- POST – Create the New Resources at the server
- PUT – Update the Existing data
- DELETE – Delete the Resource from Server
- PATCH – For Modify
6. Disadvantages of REST Services?
– Since its statelessness, the session id can be verified only through request.
– REST does not have any default security adherences, Need to Impose SSL and TLS based authentications for rest requests.
7. Difference between SOAP vs REST?
SOAP :
- Simple Object Access Protocol
- It is a protocol used to Implement the Webservices
- SOAP can not use REST as a Protocol
- SOAP is Tightly coupled with server
- SOAP has its security measures.
- SOAP is slower compared with REST
- Stateful Transfer
- SOAP Supports only XML
REST :
- Representational State transfer
- REST uses SOAP as a protocol in the Implementation
- REST is faster
- REST is more flexible as the request is sent from Browser and does not depend on any specific servers
- REST Supports XML, JSON, TXT, etc
- REST used URL to expose the resources
- REST can be cached
8. AJAX Services?
- AJAX – Asynchronous javascript and XML
- Since it is an Asynchronous call, does not require client and server interactions
- AJAX uses XMLHttpRequest object to send the request to the server and the response will be interpreted into JS dynamically.
- AJAX is used for dynamic updates without reloading the entire page.
9. What are all the Components of REST HTTP Requests?
- 1. Methods – PUT, POST, GET, DELETE what operations to be done
- 2. URI – To identify the location of resources on the server.
- 3. HTTP Version- To identify the HTTP version on the server-side. Ex: HTTP v1.1
- 4. Request Header : Contains the Request meta-data, client-type, content-format, cache-settings, message-format
- 5. Request Body − This part represents the actual message content to be sent to the server.
10. What are all the Components of REST HTTP Response?
- 1. Response Status Code – 1XX – 5XXX
- 2. HTTP Version – HTTP version of the Server
- 3. Response Header – Content-Type, Response Length, Response Date, Server Type, etc.
- 4. Response Body – Actual Response message from the Server
11. Should we make the REST Thread Safe Explicitly?
– Not Required Explicitly, Since approaching the Resources from Multiple Clients makes it to create new Object by Default.
12. How to test REST?
- Swagger, Postman for Testing
- Jmeter for Performance testing
13. Key Annotations in JAXRS-API?
- @PATH – Relative URI Path in the REST Resource
- @GET – Identify the Request as HTTP GET Request, and Process GET Request
- @POST – Identify the Request as HTTP POST Request, and process POST Request
- @PUT – Identify the Request as HTTP PUT Request, and process PUT Request
- @DELETE – Identify the Request as HTTP DELETE Request, and process DELETE Request
- @HEAD – Identify the Request as HTTP HEAD Request, and process HEAD Request
- @PathParam – Used to Extract parameters from URL for Method usage
- @QueueParam – Used to Extract Query Parameters from URI for Method usage.
- @Produces – Specify the Reponse MIME Type,
- @Consumes – Specify the Input process MIMR Type received from Clint
14. What is URI ?
- Commonly Known as Uniform Resource Identifier
- URI is a common term Used to Identify the Resource of REST Architecture
- Syntax : <protocol>://<service-name>/<ResourceType>/<ResourceID>
- URI has Two Parts – URL and URN
15. What is the Difference between URN and URL
URL :
- URL stands for Uniform Resource Locator
- URL starts with any specific protocol Such as HTTP, FTP, FILE
- URL contains 3 parts such as Protocol, Hostname, Path to Destination File/Path
URN :
- URN Stands for Uniform Resource Name
- URN is not used to locate the Resource over the Internet, Instead URN is used as a Template to find the resource over the internet.
- URN Always prefixed with urn:
- Syntax : urn:<Identifier1>:<Identifier2>:..
- URN can not be used as an HTTP protocol over the internet, but it can be used as a protocol by converting the URN into a URL using “URN resolver”.
16. What is statelessness in REST Services?
– REST Architecture is designed in a way like the session state of the Client does not identify from the server. All the server need is a request. Once the request is received, it processes it accordingly and sends back the response, it does not rely on the session state of the client. It processes everything only based on the parameters received over the request. It works independently and does not rely on any external services/applications.
17. What are the Main Disadvantages of RestFul Web services?
– It works without relying on the Session, Hence it is not possible to maintain the session if it is even required.
– REST does not provide any inbuilt security mechanism, it needs to rely on security measures such as SSL/TSL based on authentications.
18. What is Messaging Machnanism in RestFul Services?
Commonly we used to call messaging is the Interaction between two people over any intermediate platform. In the same way communicating Client and Server over the HTTP protocol, processing and receiving the message as HTTP Response. This process is called Messaging.