In this tutorial, you will learn how to send HTTP Requests using Rest Assured API Testing Library. We are going to cover all the Request types in this Rest Assured Examples article – GETPOSTPUTPATCH and  DELETE

Rest Assured Examples - GET, POST, PUT, PATCH and DELETE...!!! Share on X

Rest Assured Library Dependency Configuration:

Add the below-mentioned dependency to your maven project’s pom.xml.

 

Note: you can choose the ‘version’ of your choice.

Now, we are all set to get into the REST-assured HTTP API Requests.

In the examples below, we will test the ‘reqres.in – Sample Rest API’ which is available here. This page contains Fake Online REST API for the testing purpose which we are going to use for various CRUD operations.

In this Article, we are going to cover:

GET REQUEST

The HTTP GET request is used to request a resource from the server. In the example below, we are going to use get() method of Rest Assured Java Library.

Output:

GET REQUEST WITH QUERY PARAMETERS

Query Parameter is used to filter or sort the resources. In the example below, we are going to use queryParam() with the get() call.

Output:

GET REQUEST WITH PATH PARAMETERS

Path Parameter is used to identify a specific resource or resources. In the example below, we are going to use pathParam() with the get() call.

Output:

rest assured examples    rest assured examples

POST REQUEST

The HTTP POST request is used to send data to a server to create the resource. In the example below, we are going to use post() method of Rest Assured Java Library and sending the data while making the call. 

Output:

rest assured examples    rest assured examples

PUT REQUEST

PUT request is used to update the resource on the server. In the example below, we are going to use put() method and supply the data while making the call. 

Output:

rest assured examples    rest assured examples

PATCH REQUEST

PATCH request is also used to update the resource just like PUT request but only required to send the only data which is required to be updated. In the example below, we are going to use patch() method and supply the data while making the call. 

Output:

rest assured examples    rest assured examples

DELETE REQUEST

DELETE request is used to delete the resource on the server. In the example below, we are going to use delete() method.

Output:

Elaborative and yet easy representation of REST API testing using a REST Assured examples...!!! Share on X

Do you like this Post? – then check out my other helpful posts:

Other Useful References

Author

  • Deepak Verma

    Deepak Verma is a Test Automation Consultant and Software development Engineer for more than 10 years. His mission is to help you become an In-demand full stack automation tester. He is also the founder of Techndeck, a blog and online coaching platform dedicated to helping you succeed with all the automation basics to advanced testing automation tricks.

    http://Techndeck.com deepak.rkgit@gmail.com Verma Deepak