Top 16 REST API Testing Interview Questions With Answers!!
Many testers will definitely need to face interview questions when applying for a QA job. The web API testing interview questions below have been collected from the test professionals to help you get ready for a new role. More than just an API interview, this list of content will also benefit both freshers and senior testers who would like to achieve both general and advanced knowledge in REST API testing. So lets see these comprehensive answers for all the collected Rest API Testing Interview Questions.
1. What is REST?
REST (Representational State Transfer) is an architectural style for developing web services which exploit the ubiquity of HTTP protocol and uses the HTTP method to define actions. It revolves around resource where every component being a resource that can be accessed through a shared interface using standard HTTP methods.
In REST architecture, a REST Server provides access to resources and REST client accesses and makes these resources available. Here, each resource is identified by URIs or global IDs, and REST uses multiple ways to represent a resource, such as text, JSON, and XML. XML and JSON are nowadays the most popular representations of resources.
2. What is a RESTFul Web Services?
Mostly, there are two kinds of Web Services which should be remembered in your next API testing interview:
- SOAP (Simple Object Access Protocol) – an XML-based method to expose web services.
- Web services developed in the REST style are referred to 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 like JSON and a set of HTTP methods.
3. What is a “Resource” in REST?
REST architecture treats any content as a resource, which can be either text files, HTML pages, images, videos or dynamic business information.
REST Server gives access to resources and modifies them, where each resource is identified by URIs/ global IDs.
4. What is the most popular way to represent a resource in REST?
REST uses different representations to define a resource like text, JSON, and XML.
XML and JSON are the most popular representations of resources.
5. 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.
6. What are some key characteristics of REST?
Key characteristics of REST are likely asked in a Web API Testing interview. So please get the answer ready in your mind with these 2 ones:
- REST is stateless, therefore the SERVER has no status (or session data)
With a well-applied REST API, the server could be restarted between two calls, since all data is transferred to the server - Web service uses POST method primarily to perform operations, while REST uses GET for accessing resources.
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 when the client sends a message in the form of an HTTP Request, the server sends back the HTTP reply is called Messaging. These messages comprise message data and metadata, that is, information on the message itself.
8. What are the core components of an HTTP request?
An HTTP request contains five key elements:
- An action showing HTTP methods like GET, PUT, POST, DELETE.
- Uniform Resource Identifier (URI), which is the identifier for the resource on the server.
- HTTP Version, which indicates HTTP version, for example-HTTP v1.1.
- Request Header, which carries metadata (as key-value pairs) for the HTTP Request message. Metadata could be a client (or browser) type, format supported by the client, format of a message body format, cache settings, and so on.
- Request Body, which indicates the message content or resource representation.
9. What are the most commonly used HTTP methods supported by REST?
- GET is only used to request data from a specified resource. Get requests can be cached and bookmarked. It remains in the browser history and haS length restrictions. GET requests should never be used when dealing with sensitive data.
- POST is used to send data to a server to create/update a resource. POST requests are never cached and bookmarked and do not remain in the browser history.
- PUT replaces all current representations of the target resource with the request payload.
- DELETE removes the specified resource.
- OPTIONS is used to describe the communication options for the target resource.
- HEAD asks for a response identical to that of a GET request, but without the response body.
10. Can GET request to be used instead of PUT to create a resource?
The PUT or POST method should not be used to create a resource. You can use the GET operation which has view-only rights.
11. Is there any difference between PUT and POST operations?
PUT and POST operation are quite similar, except the terms of the result generated by them.
PUT operation is idempotent, so you can cache the response while the responses to POST operation are not cacheable, and if you retry the request N times, you will end up having N resources with N different URIs created on server.
In a Web API Testing interview, you should give a specific example for PUT and POST operations to make crystal clear to the interviewer. Below is an example:
Scenario: Let’s say we are designing a network application. Let’s list down few URIs and their purpose to get to know when to use POST and when to use PUT operations.
GET /device-management/devices : Get all devices
POST /device-management/devices : Create a new device
GET /device-management/devices/{id} : Get the device information identified by “id”
PUT /device-management/devices/{id} : Update the device information identified by “id”
DELETE /device-management/devices/{id} : Delete device by “id”
12. Which 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.
13. What is URI? What is the main purpose of REST-based web services and what is its format?
URI stands for Uniform Resource Identifier. It is a string of characters designed for unambiguous identification of resources and extensibility via the URI scheme.
The purpose of a URI is to locate a resource(s) on the server hosting of the web service.
A URI’s format is <protocol>://<service-name>/<ResourceType>/<ResourceID>.
14. What is payload in RESTFul Web services?
The “payload” is the data you are interested in transporting. This is differentiated from the things that wrap the data for transport like the HTTP/S Request/Response headers, authentication, etc.
15. What is the upper limit for a payload to pass in the POST method?
<GET> appends data to the service URL. But, its size shouldn’t exceed the maximum URL length. However, <POST> doesn’t have any such limit.
So, theoretically, a user can pass unlimited data as the payload to POST method. But, if we consider a real use case, then sending POST with large payload will consume more bandwidth. It’ll take more time and present performance challenges to your server. Hence, a user should take action accordingly.
16. What is the caching mechanism?
Caching is just the practice of storing data in temporarily and retrieving data from a high-performance store (usually memory) either explicitly or implicitly.
When a caching mechanism is in place, it helps improve delivery speed by storing a copy of the asset you requested and later accessing the cached copy instead of the original.
Ready to succeed in your next Web API Testing interview
API testing interview questions can be unlimited regarding of the number of questions and area covered. Although the above answers might not fully be used in your interview, we do hope it somehow provides the solid understanding on REST API testing interview questions and gets you ready for the upcoming job and project related to API testing.
Wish you confidence and luck in your testing career! If you have any suggestions on this topic, please do not hesitate to add to here. We look forward to a better and more adequate list to all testers.
This is a fantastic blog from which people can learn a lot. It is very informative and is explained in…
Thanks for sharing such knowledgeable Content on Automation testing, to know how to enhance the performance of ERP's like Oracle…
Thanks.. this list is much needed.
This one is also good to use. Thanks for sharing this.. Might be we can also add it in list…
How about youtube-dl?