Automating POST and PUT Request Using Rest Assured

Automating POST and PUT Request Using Rest Assured

In the previous blog, we already have seen how to Automate GET and Delete Request using Rest Assured. In this blog, we would be looking into how to automate POST and PUT Requests.

In this example, I would be continuing with the same website which we are using in our previous blogs.

As we already discussed in order to use Rest Assured effectively we need to do some static import manually in our IDE.

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;

While working with POST and PUT Request we need to pass the JSON body along with Authorization Key (if applicable) and Header.

Let’s now start with POST Request.

As shown in the below screenshot once we fire the POST Request to Server it will respond back with status Code 201 which means the request is created on the server along with the JSON response body.

In this case, our Base URI is: and successive URI for passing POST request is “/api/users”

Now let’s fire the same request in Postman and validate the response Header along with Body of the JSON Response.

As we can see in the above screenshot we are getting the same response along with some additional details which will ultimately help us to validate different scenarios while doing API Testing.

As we discussed already while working with POST and PUT request we need to pass the Body in JSON  Request Format. Please use this link to convert JSON Body into that specific format.

Below is the code for creating the list of the user. In this code for validating any specific response in the Header, we need to use a header of the JSON Body we got in postman response.

Below is the output after Code execution.

Similarly, we can use below PUT request which will respond back with status code 200.



My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
July 19, 2019 at 6:16 PM

i want more scripts on webservices api for automation scripts .Anyone please help me

November 1, 2019 at 11:37 PM

Hi , please do a katalon studio API testing. Currently we are using .

January 23, 2020 at 5:26 PM

You ought to basically fantastic not to mention solid advice, which means notice: ecommerce hosting

May 25, 2020 at 1:48 AM

How you create a generic post call that handle auth user and guest user scenario.

June 6, 2020 at 3:13 PM

Nice post mate, keep up the great work, just shared this with my friendz download instagram likes and likes app