REST API Interview Questions And Answers For Software Testers

The common information about REST API for Interview section.

api testing, www.techsouljours.blogspot.com
API testing interview questions and answers

1) Explain what is REST and RESTFUL?
REST:
REST represents REpresentational  State Transfer; it is a relatively new aspect of writing web API.   In REST architecture, a REST Server provides access to resources and REST client accesses and presents those resources. Here each resource is identified by URIs or global IDs. REST uses different ways to represent a resource like text, JSON, and XML. XML and JSON are the most popular representations of resources these days.
RESTFUL Web Service
Mostly, there are two kinds 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 known as RESTful web services. These web services use HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation such as JSON and set of HTTP Methods.
2) 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
3) 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 update 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

4) Which Protocol Is Used By RESTful Web Services?

RESTful web services make use of HTTP protocol as a medium of communication between client and server.

5) What Is Messaging In RESTful Web Services?

RESTful web services make use of HTTP protocol as a medium of communication between client and server. The client sends a message in the form of an HTTP Request.
In response, the server transmits the HTTP Response. This technique is called Messaging. These messages contain message data and metadata i.e. information about the message itself.

6) Explain What Is A “Resource” In REST?

REST architecture treats every content as a resource. These resources can be either text files, HTML pages, images, videos or dynamic business data.
REST Server provides access to resources and REST client accesses and modifies these resources. Here each resource is identified by URIs/ global IDs.
7) State The Core Components Of An HTTP Request?
Each HTTP request includes five key elements.
1. The Verb which indicates HTTP methods such as GET, PUT, POST, DELETE.
2. URI stands for Uniform Resource Identifier (URI).It is the identifier for the resource on the server.
3. HTTP Version which indicates HTTP version, for example-HTTP v1.1.
4. Request Header carries metadata (as key-value pairs) for the HTTP Request message. Metadata could be a client (or browser) type, the format that client supports, message body format, and cache settings.
5. Request Body indicates the message content or resource representation.

8) State The Core Components Of An HTTP Response?

Every HTTP response includes four key elements.
1. Status/Response Code – Indicates Server status for the resource present in the HTTP request.For example, 404 means resource not found and 200 means response is ok.
2. HTTP Version – Indicates HTTP version, for example-HTTP v1.1.
3. Response Header – Contains metadata for the HTTP response message stored in the form of key-value pairs. For example, content length, content type, response date, and server type.
4. Response Body – Indicates response message content or resource representation.
9) 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
10) Mention which markup language can be used in restful web api for resources?
JSON and XML are the two markup language that can be used in restful web api
11) Mention what is the difference between SOAP and REST?
SOAPREST
  • SOAP is a protocol through which two computer communicates by sharing XML document
  • SOAP permits only XML
  • SOAP based reads cannot be cached
  • SOAP is like custom desktop application, closely connected to the server
  • SOAP is slower than REST
  • It runs on HTTP but envelopes the message
  •  Rest is a service architecture and design for network-based software architectures
  • REST supports many different data formats
  • REST reads can be cached
  • A REST client is more like a browser; it knows how to standardized methods and an application has to fit inside it
  • REST is faster than SOAP
  • It uses the HTTP headers to hold meta information

12) What Is URI? Explain Its Purpose In REST Based Web Services. What Is Its Format?

URI stands for Uniform Resource Identifier. URI is the identifier for the resource in REST architecture.
The purpose of a URI is to locate a resource(s) on the server hosting the web service. A URI is of the following format-
<protocol>://<service-name>/<ResourceType>/<ResourceID>

13) What Do You Understand By Payload In RESTFul Web Service?

Request body of every HTTP message includes request data called as Payload. This part of the message is of interest to the recipient.
We can say that we send the payload in POST method but not in <GET> and <DELTE> methods.

14) Explain The Caching Mechanism?

Caching is a process of storing server response at the client end. It makes the server save significant time from serving the same resource again and again. 

15) Can You Tell Us Which Java API Helps In Developing A RESTFul Web Service?

There are many frameworks and libraries available that a developer can use to create RESTful web services in Java. For example, the JAX-RS library is a standard way to develop a REST web service.
Regards
.
Post author by Senior QA Venkatesh.S

2 comments: