Rest Api
Rest Api
Use the GET option because it has view-only rights. The POST or PUT methods should never be used
to create a resource.
@Test
public void GetAllEmoloyees()
{
// base URL to call
RestAssured.baseURI =
"http://localhost:8080/employees/get";
}
}
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- UNAUTHORIZED - This is returned when there is no valid
authentication credentials sent along with the request.
403 - 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.
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.