Rest Assured
Rest Assured
com/tag/restassured/
What happens when you type a URL in the browser and press enter?
https://medium.com/@maneesha.wijesinghe1/what-happens-when-you-type-an-url-in-the-browser-
and-press-enter-bb0aa2449c1a
http codes :
https://www.restapitutorial.com/httpstatuscodes.html
2xx Success
This class of status code indicates that the client's request was successfully received, understood, and
accepted.
Wikipedia
This class of status codes indicates the action requested by the client was received, understood,
accepted and processed successfully.
200 OK
201 Created
202 Accepted
204 No Content
https://www.guru99.com/rest-api-interview-question-answers.html
https://www.softwaretestingmaterial.com/api-testing-interview-questions/
https://www.katalon.com/resources-center/blog/web-api-testing-interview-questions/
https://career.guru99.com/top-20-questions-on-api-testing/
https://www.softwaretestinghelp.com/api-testing-interview-questions-and-answers/
What is an API?
API is the acronym for Application Programming Interface. It is a software interface
that allows two applications to interact with each other without any user
intervention.
Web service is a collection of open source protocols and standards used for
exchanging data between systems or applications whereas API is a software
interface that allows two applications to interact with each other without
any user involvement.
Web service is used for REST, SOAP and XML-RPC for communication while
API is used for any style of communication.
Web service supports only HTTP protocol whereas API supports
HTTP/HTTPS protocol.
Web service supports XML while API supports XML and JSON.
All Web services are APIs but all APIs are not web services.
A microservice is an architectural design that separates
containing services.
1. What is an API?
API is an acronym and it stands for Application Programming Interface.
API is a set of routines, protocols, and tools for building Software
Applications. APIs specify how one software program should interact
with other software programs.
Unit testing
Functional testing
Load testing
Runtime/ Error Detection
Security testing
UI testing
Interoperability and WS Compliance testing
Penetration testing
Fuzz testing
POST should be used when the client sends the page to the server and
then the server lets the client know where it put it. PUT should be used
when the client specifies the location of the page
Don’t Miss:
28. What is the HTTP response code for a POST request with
incorrect parameters?
400 Bad Request is an ideal response code for request with incorrect
parameters.
REST is very important and beneficial in Web API because of the following
reasons:
For example:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle=" http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<Demo.guru99WebService xmlns="http://tempuri.org/">
<EmployeeID>int</EmployeeID>
</Demo.guru99WebService>
</soap:Body>
</SOAP-ENV:Envelope>
REST SOAP
It is basically an architectural
pattern. It is basically a messaging protocol.
It usually works with various text
formats such as plain text, HTML,
JSON, XML, etc. It only works with XML formats.
It has some specifications for both stateless and
It is totally stateless. stateful implementation.
Its performance is faster as
compared to SOAP. Its performance is slower as compared to REST.
It uses WSDL (Web Service Description
It uses XML and JSON to send and Language) for communication among
receive data. consumers or users and providers.
SOAP includes built-in error handling for
REST has to resend transfer communications errors using WS-
whenever it determines any errors. ReliableMessaging specification.
It calls services by calling RPC (Remote
It calls services using the URL path. Procedure Call) method.
12. Which of the following Open-source libraries is used by WEB API for JSON
serialization?
HTTP GET: This method is used to get information or data from a respective
server at a specified URL.
Example:
GET/RegisterStudent.asp?user=value1&pass=value2
Example:
POST/RegisterStudent.asp HTTP/1.1
Host: www.guru99.com
user=value1&pass=value2
HTTP GET HTTP POST
Its parameters are included in
the URL. Its parameters are included in the body.
This method is used to request
data from specified resources This method is used to send data to a server to
and has no other effect. create or update resources.
It carries request parameters in the message body
It carries a request parameter that make it a more secure way of sending data or
appended in the URL string. information from the client to the server.
Request method using GET is Request method using POST is not cacheable.
HTTP GET HTTP POST
cacheable.
GET requests are less safe than
POST. Post request is safer than GET.
There is a restriction on data
type in GET method and only There are no restrictions on data type in this
ASCII characters are allowed. method and binary data is also allowed.
Data is visible to everyone in the Data is not displayed in the URL. It is present in
URL. the payload.
RESTful web services are services that follow REST architecture. REST stands
for Representational State Transfer and uses HTTP protocol (web protocol)
for implementation. These services are lightweight, provide maintainability,
scalability, support communication among multiple applications that are
developed using different programming languages. They provide means of
accessing resources present at server required for the client via the web
browser by means of request headers, request body, response body, status
codes, etc.
The REST Server provides access to these resources whereas the REST client
consumes (accesses and modifies) these resources. Every resource is
identified globally by means of a URI.
3. What is URI?
Uniform Resource Identifier is the full form of URI which is used for
identifying each resource of the REST architecture. URI is of the format:
<protocol>://<service-name>/<ResourceType>/<ResourceID>
The REST architecture is designed in such a way that the client state is not
maintained on the server. This is known as statelessness. The context is
provided by the client to the server using which the server processes the
client’s request. The session on the server is identified by the session
identifier sent by the client.
6. What do you understand by JAX-RS?
As the name itself stands (JAX-RS= Java API for RESTful Web Services) is a
Java-based specification defined by JEE for the implementation of RESTful
services. The JAX-RS library makes usage of annotations from Java 5
onwards to simplify the process of web services development. The latest
version is 3.0 which was released in June 2020. This specification also
provides necessary support to create REST clients.
These are the standard codes that refer to the predefined status of the task
at the server. Following are the status codes formats available:
200 - success/OK
201 - CREATED - used in POST or PUT methods.
304 - NOT MODIFIED - used in conditional GET requests to reduce the
bandwidth use of the network. Here, the body of the response sent should
be empty.
400 - BAD REQUEST - This can be due to validation errors or missing input
data.
401 - FORBIDDEN - sent when the user does not have access (or is
forbidden) to the resource.
404 - NOT FOUND - Resource method is not available.
500 - INTERNAL SERVER ERROR - server threw some exceptions while
running the method.
502 - BAD GATEWAY - Server was not able to get the response from another
upstream server.
8. What are the HTTP Methods?
HTTP Methods are also known as HTTP Verbs. They form a major portion of
uniform interface restriction followed by the REST that specifies what action
has to be followed to get the requested resource. Below are some examples
of HTTP Methods:
GET: This is used for fetching details from the server and is basically a read-
only operation.
POST: This method is used for the creation of new resources on the server.
PUT: This method is used to update the old/existing resource on the server
or to replace the resource.
DELETE: This method is used to delete the resource on the server.
PATCH: This is used for modifying the resource on the server.
OPTIONS: This fetches the list of supported options of resources present on
the server.
The POST, GET, PUT, DELETE corresponds to the create, read, update,
delete operations which are most commonly called CRUD Operations.
GET, HEAD, OPTIONS are safe and idempotent methods
whereas PUT and DELETE methods are only idempotent.
POST and PATCH methods are neither safe nor
idempotent.
The technique of sending a message from the REST client to the REST
server in the form of an HTTP request and the server responding back with
the response as HTTP Response is called Messaging. The messages
contained constitute the data and the metadata about the message.
REST API Experienced Interview Questions
11. Differentiate between SOAP and REST?
SOAP REST
SOAP - Simple Object Access
Protocol REST - Representational State Transfer
SOAP is a protocol used to REST is an architectural design pattern for
implement web services. developing web services
SOAP cannot use REST as it is a REST architecture can have SOAP protocol as
protocol. part of the implementation.
SOAP specifies standards that are REST defines standards but they need not be
meant to be followed strictly. strictly followed.
SOAP REST
SOAP client is more tightly The REST client is more flexible like a browser
coupled to the server which is and does not depend on how the server is
similar to desktop applications developed unless it follows the protocols required
having strict contracts. for establishing communication.
SOAP supports only XML
transmission between the client REST supports data of multiple formats like XML,
and the server. JSON, MIME, Text, etc.
SOAP reads are not cacheable. REST read requests can be cached.
SOAP uses service interfaces for
exposing the resource logic. REST uses URI to expose the resource logic.
SOAP is slower. REST is faster.
Since SOAP is a protocol, it REST only inherits the security measures based
defines its own security measures. on what protocol it uses for the implementation.
SOAP is not commonly preferred,
but they are used in cases which REST is commonly preferred by developers these
require stateful data transfer and days as it provides more scalability and
more reliability. maintainability.
12. While creating URI for web services, what are the best practices that
needs to be followed?
Below is the list of best practices that need to be considered with designing
URI for web services:
RESTful web services use REST API as means of implementation using the
HTTP protocol. REST API is nothing but an application programming
interface that follows REST architectural constraints such as statelessness,
cacheability, maintainability, and scalability. It has become very popular
among the developer community due to its simplicity. Hence, it is very
important to develop safe and secure REST APIs that follow good
conventions. Below are some best practices for developing REST APIs:
16. Can you tell what constitutes the core components of HTTP Request?
Request Body − This part represents the actual message content to be sent
to the server.
Response Status Code − This represents the server response status code for
the requested resource. Example- 400 represents a client-side error, 200
represents a successful response.
HTTP Version − Indicates the HTTP protocol version.
Response Header − This part has the metadata of the response message.
Data can describe what is the content length, content type, response date,
what is server type, etc.
Response Body − This part contains what is the actual resource/message
returned from the server.
<protocol>://<application-name>/<type-of-resource>/<id-of-resource>
19. What are the differences between PUT and POST in REST?
PUT POST
PUT methods are used to request the server to store
the enclosed entity in request. In case, the request POST method is used to
does not exist, then new resource has to be created. request the server to store the
If the resource exists, then the resource should get enclosed entity in the request
updated. as a new resource.
The POST URI should indicate
The URI should have a resource identifier. the collection of the resource.
Example: PUT /users/{user-id} Example: POST /users
21. Based on what factors, you can decide which type of web services you
need to use - SOAP or REST?
Following are the questions you need to ask to help you decide which
service can be used:
The request flow difference between the REST and Web Socket is shown
below:
23. Can we implement transport layer security (TLS) in REST?
Yes, we can. TLS does the task of encrypting the communication between
the REST client and the server and provides the means to authenticate the
server to the client. It is used for secure communication as it is the
successor of the Secure Socket Layer (SSL). HTTPS works well with both TLS
and SSL thereby making it effective while implementing RESTful web
services. One point to mention here is, the REST inherits the property of the
protocol it implements. So security measures are dependent on the protocol
REST implements.
24. Should we make the resources thread safe explicitly if they are made to
share across multiple clients?
Payload refers to the data passes in the request body. It is not the same as
the request parameters. The payload can be sent only in POST methods as
part of the request body.
26. Is it possible to send payload in the GET and DELETE methods?
No, the payload is not the same as the request parameters. Hence, it is not
possible to send payload data in these methods.
RESTful web services can be tested using various tools like Postman,
Swagger, etc. Postman provides a lot of features like sending requests to
endpoints and show the response which can be converted to JSON or XML
and also provides features to inspect request parameters like headers,
query parameters, and also the response headers. Swagger also provides
similar features like Postman and it provides the facility of documentation
of the endpoints too. We can also use tools like Jmeter for performance and
load testing of APIs.
28. What is the maximum payload size that can be sent in POST methods?
30. What is the difference between idempotent and safe HTTP methods?
Safe methods are those that do not change any resources internally. These
methods can be cached and can be retrieved without any effects on the
resource.
Idempotent methods are those methods that do not change the responses
to the resources externally. They can be called multiple times without any
change in the responses.
According to restcookbook.com, the following is the table that describes
what methods are idempotent and what is safe.
HTTP Idempote Saf
Methods nt e
OPTIONS yes yes
GET yes yes
HEAD yes yes
PUT yes no
POST no no
DELETE yes no
PATCH no no
JAX-RS stands for Java API for RESTful Web services. They are nothing but a
set of Java-based APIs that are provided in the Java EE which is useful in the
implementation and development of RESTful web services.
Example:
import javax.ws.rs.Path;
/**
* InterviewBitService is a root resource class that is exposed at
'resource_service' path
*/
@Path('resource_service')
public class InterviewBitService {
// Defined methods
}
33. What do you understand by request method designator annotations?
They are the runtime annotations in the JAX-RS library that are applied to
Java methods. They correspond to the HTTP request methods that the
clients want to make. They are @GET, @POST, @PUT, @DELETE, @HEAD.
Usage Example:
import javax.ws.rs.Path;
/**
* InterviewBitService is a root resource class that is exposed at
'resource_service' path
*/
@Path('resource_service')
public class InterviewBitService {
@GET
public String getRESTQuestions() {
// some operations
}
}
34. How can the JAX-RS applications be configured?
JAX-RS applications have the root resource classes packaged in a war file.
There are 2 means of configuring JAX-RS applications.
Let us consider we have this function below which is used for processing 2
Ids parallelly.
The RestTemplate is the main class meant for the client-side access for
Spring-based RESTful services. The communication to the server is
accomplished using the REST constraints. This is similar to other template
classes such as JdbcTemplate, HibernateTemplate, etc provided by Spring.
The RestTemplate provides high-level implementation details for the HTTP
Methods like GET, POST, PUT, etc, and gives the methods to communicate
using the URI template, URI path params, request/response types, request
object, etc as part of arguments.
@PathVariable annotation is used for passing the parameter with the URL
that is required to get the data. Spring MVC provides support for URL
customization for data retrieval using @PathVariable annotation.
We have seen what are the most commonly asked questions on RESTful
web services during an interview. REST APIs have become a very important
tool in the software industry. Developing RESTful web services that are
scalable and easily maintainable is considered an art. As the industry
trends increase, the REST architecture would become more concrete and
the demand for developers who know the development of RESTful web
services would increase steadily.
https://www.interviewbit.com/rest-api-interview-questions/
Parameter Selection
Parameter Combination
Call sequencing
Swagger
Miredot
Slate
FlatDoc
API blueprint
RestDoc
22. What kinds of bugs that API testing would often find?
Stress
Reliability
Security
Unused flags
Not implemented errors
Performance
Parameter Selection
Parameter Combination
Call sequencing
19. What are the testing methods that come under API testing?
20. Why is API testing considered as the most suitable form for
Automation testing?
Documentation errors
22. What kinds of bugs that API testing would often find?
Stress
Reliability
Security
Unused flags
Performance
Multi-threading issues
Improper errors
https://www.iteanz.com/api-interview-questions-and-answers/
https://mediatemple.net/community/products/dv/204644990/why-am-i-getting-a-
500-internal-server-error-message
For every request that is sent to a server, there is an http status code that is
returned. These status codes will be returned as a 3 digit number (200, 403,
404, 500, 502, etc). Each of these numbers provide some indication as to
what type of issue is preventing your site from loading. The 5XX errors
indicate that a request has been sent to the server, but some technical issue
has prevented this request from being completed.
The 500 Internal Server Error in particular is a catch-all error message, given
when no more specific message is suitable. There can be a number of
causes for a 500 Internal Server Error to display in a web browser. Below is a
sample of what a 500 error message will look like.
COMMON CAUSES
Below are common troubleshooting steps that can be taken to resolve a 500
Internal Server Error:
1. Check the error logs
2. Check the .htaccess file
3. Check your PHP resources
4. Check CGI/Perl scripts
With any error message, particularly one as broad as the 500 Internal Server
Error, you will first want to check any Apache and PHP error logs for your
server. These logs can provide valuable context related to any code failures or
other potential causes of a site failure. For information on where to find the
logs for your server, please see: Where are the access_log and error_log for
my server?
If you are using a .htaccess on your site, it may be interfering with the web
page you are trying to load into your
You don't know what exactly happened or why it happened — all you know is
that something's wrong and you need to fix it.
To guide you through the hassle of troubleshooting the dreaded HTTP 500
internal server error, let's go over what it exactly means and its most common
causes and solutions.
Here's what your 500 error page might look like in your browser:
So, let's dive into a few potential causes of the error. Then, we'll present some
solutions so you can try to fix the issue.
A 500 internal server error is, as the name implies, a general problem with the
website's server. More than likely, this means there's an issue or temporary
glitch with the website's programming.
A permissions error
This might seem obvious, but if it's a temporary loading issue, you might find
success if you refresh the page. Before trying anything else in this list, reload
the page and see what happens.
Since the error is on the server side, I'm willing to bet the website owners are
working as quickly as possible to resolve the issue. Give it a few minutes or
up to an hour or so, and then reload the URL and see if the development team
has fixed the issue.
If clearing the browser history doesn't work, you might try deleting your
browser's cookies. If the cookies are associated with the error-prone
webpage, deleting the cookies might help reload the page.
4. Paste your URL into the website "Down for Everyone or Just Me."
If you run a WordPress website, this is easy to do with plugins. From your
dashboard, choose Plugins > Installed Plugins, then deactivate the
first plugin. If the error resolves, you know this plugin is part of the issue.
Reactivate the first plugin, then repeat this deactivate-reactivate process one
at a time for all plugins to determine which ones are causing your error.
You might find that having fewer active plugins on your site helps things run
more smoothly.
The debug plugin WP Debugging, for instance, helps you figure out
exactly what's wrong with your site, which will result in a speedier fix.
Image Source
Incorrect coding or improper structure with your .htaccess file could be the
reason you're seeing the 500 internal error. The .htaccess file helps you
manage how long resources should be stored in a browser's cache. Try
editing the file if you're seeing a 500 internal server error.
To locate your .htaccess file, access your website files through a file manager
like cPanel or via FTP/SFTP. The file will probably be located in
your public_html directory. There's a good chance your server will hide this
file from view by default and you'll need to toggle hidden files on to see it.
Image Source
Coding errors in .htaccess and custom scripts can also cause an HTTP 500
internal server error.
You can also ask your service provider to access your error logs and find
evidence for the root cause of your problem.
Internal server errors are irritating because they're unhelpful — it's basically
the web server's way of saying, "Eh, I'm not sure." Hopefully, one of the above
steps will resolve the problem so you can get back to life as usual.