REST API Interview Questions and Answers

Orange TechnoMind 26-Feb-2021
orange technomind

Here we providing a comprehensive list of Rest API testing interview questions and answers.The questionnaire will begin with the basics of REST API testing and through the advanced concepts.So you should also equip yourself with information to encounter questions from the interviewers and do well in the Software testing interviews.
 
 
1. What is REST?
REST stands for Representational State Transfer, a web standards-based architecture and utilizes HTTP Protocol for data communication. It revolves around resources where wherever each component could be a resource is accessed by a common interface exploitation HTTP standard methods. REST was 1st introduced by Roy Fielding in 2000.
In REST architecture, a REST Server provides access to resources and REST client accesses and makes these resources available. Here, every resource is known by URIs or global IDs, and REST uses multiple ways that to represent a resource, like text, JSON, and XML. XML and JSON are today the foremost well-liked representations of resources.
 
2.What Are Web Services?
Answer: A web service is a collection of open protocols and standards utilized for exchanging data between applications or systems. Software applications written in numerous programming languages and running on numerous platforms will use web services to exchange data over computer networks like the Internet just like the inter-process communication on a single computer.
 
3.Explain the RESTFul Web Service?
Mostly, there are two sorts of Web Services which are quite popular.
1. SOAP (Simple Object Access Protocol) which is an XML-based way to expose web services.
2. Web services developed using REST style are referred as RESTful web services. These web services use HTTP methods to implement the idea of REST architecture. A RESTful web service typically defines a URI, Uniform Resource Identifier a service, provides resource representation like JSON and set of HTTP Methods.
 
4.Enlist some of the commonly used Http Methods in Rest Based Architecture?
Here are the following HTTP methods which are utilized in REST-based architecture:
  • GET − Provides read-only access to a resource.
  • PUT − Used to create a new resource.
  • DELETE − Used to remove a resource.
  • POST − Utilized to update an existing resource or create a new resource.
  • OPTIONS − Utilized to get the supported operations on a resource.
5.How to represent a resource in Rest?
REST uses numerous representations to represent a resource wherever text, JSON, XML. XML and JSON are the foremost well-liked representations of resources.
 
6.Which protocol is used by RESTful Web services?
RESTful web services use the HTTP protocol as a medium of communication between the client and the server.
 
7.What is messaging in RESTful Web services?
RESTful web services use the HTTP protocol as a communication tool between the client and the server. The technique that once the client sends a message within the form of an http Request, the server sends back the http reply is termed messaging. These messages comprise message information and metadata, that is, information on the message itself.
 
8.What are the core components of an HTTP request?
An HTTP Request has five major components 
  • Verb − Indicate hypertext transfer protocol ways like GET, POST, DELETE, PUT, etc.
  • URI − Uniform Resource symbol (URI) to spot the resource on the server.
  • HTTP Version − Indicate hypertext transfer protocol version, as an example hypertext transfer protocol v1.1 .
  • Request Header − Contains information for the hypertext transfer protocol Request message as key-value pairs. as an example, client ( or browser) kind, format supported by the client, format of the message body, cache settings, etc.
  • Request Body − Message content or Resource illustration.
9.Name the core components of an HTTP Response?
An HTTP Response has four major components
  • Status/Response Code − Indicate Server status for the requested resource. as an example, 404 means that resource not found and 200 means that response is ok.
  • HTTP Version − Indicate hypertext transfer protocol version, as an example hypertext transfer protocol v1.1 .
  • Response Header − Contains metadata for the HTTP Response message as key-value pairs. For example, content length, content type, response date, server type, etc.
  • Response Body − Response message content or Resource representation.
10.Can GET request to be used instead of PUT to create a resource?
The PUT or POST method shouldn't be accustomed create a resource. you'll be able to use the GET operation that has view only rights.
 
11.For what purpose does the OPTIONS method serve for the RESTful Web services?
The OPTIONS Method lists down all the operations of a web service supports. It creates read-only requests to the server.
 
12.What is Uri and its Purposes in Rest Based Web Services?
URI stands for Uniform Resource Identifier.It is a string of characters designed for unambiguous identification of resources and extensibility via the URI scheme.Each resource during a REST architecture is identified by its URI.The purpose of a URI is to find a resource(s) on the server hosting the web service.
 
13.What is format of a Uri in Rest?
A URI’s format is :////.
 
14.What is payload in RESTFul Web services?
The payload in RESTFul Web services is the data you are interested in transporting. This an be differentiated from the items that wrap the data for transport like the HTTP/S Request/Response headers, authentication, and much more.
 
15.What is the caching mechanism?
Caching is simply the apply of storing information in briefly and retrieving information from a superior store (usually memory) either expressly or implicitly.When a caching mechanism is in place, it helps improve delivery speed by storing a duplicate of the asset you requested and later accessing the cached copy rather than the first.
 
16. Mention some key characteristics of REST?
Some key characteristics of REST includes
  • REST is stateless, so 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
17.Mention which markup language can be used in restful web api?
JSON and XML are the two markup language that can be used in restful web api
 
18.What is the difference between SOAP and REST?
 

SOAP 

REST

Stands for Simple Object Access Protocol

Stands for REpresentational State Transfer

Protocol

 Architectural style

To expose the business logic SOAP uses services interfaces

To expose business logic REST uses URI

SOAP defines standards to be strictly followed

REST does not define too much standards like SOAP

Permits XML data format only

Permits different data format such as Plain text, HTML, XML, JSON etc.

SOAP requires more bandwidth and resource than REST

REST requires less bandwidth and resource than SOAP

Defines its own security

RESTful web services inherit security measures from the underlying transport.

 
19.What are the tools available for testing web services?
The tools that can help in testing the SOAP and RESTful web services are
1. SOAP UI tool.
2. Poster for Firefox browser.
3. The Postman extension for Chrome.
 
20.What do you mean by Idempotent Operation?
Idempotent operations  mean their outcome will consistently similar regardless of how often these tasks are invoked.
 
21.Which type of Web Services Methods are to be Idempotent?
PUT and DELETE operations are idempotent.
 
22.Which type of Web Services Methods are to be Read-Only?
GET operations are read-only and are safe.
 
23.What is the difference between Put And Post Operations?
is almost the equivalent with the distinction lying just in the result where PUT activity is idempotent and POST activity can cause an alternate result. 
 
24.What is the purpose of the HTTP Status Code?
HTTP Status code is standard code and refers to the predefined status of the task has been successfully completed at the server. 
For Example:
HTTP Status Code 200-  OK
HTTP Status Code 201-  CREATED 
HTTP Status Code 204-  NO CONTENT
HTTP Status Code 304-  NOT MODIFIED
HTTP Status Code 400-  BAD REQUEST
HTTP Status Code 401-  FORBIDDEN
HTTP Status Code 404-  NOT FOUND
HTTP Status Code 409-  CONFLICT
HTTP Status Code 500-  INTERNAL SERVER ERROR
 
25.What is Jax-rs?
JAX-RS represents for Java API for RESTful Web Services. It likewise support for creating clients for RESTful web services.

Contact Us

If you have a question, we have an answer. If you need something, we'll help you. Contact us anytime.

For enrollment related queries & support

+91 99 40 550 285

For technical issues & support

orangetechnomind@gmail.com