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 https://reqres.in/ 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: https://reqres.in/ 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 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.
i want more scripts on webservices api for automation scripts .Anyone please help me
ReplyHi , please do a katalon studio API testing. Currently we are using .
ReplyYou ought to basically fantastic not to mention solid advice, which means notice: ecommerce hosting
ReplyHow you create a generic post call that handle auth user and guest user scenario.
ReplyNice post mate, keep up the great work, just shared this with my friendz download instagram likes and likes app
ReplyHii
ReplyYou can also checkout https://onlinestringtools.org/ for password generator,string to upper,lower case & many more.
Do checkout this site!
I was searching for this sort of data and appreciated perusing this one. best touch switches
ReplySees for handwriting a particularly key region, I reeled close to your blog other than expect a little pack support. I really need your tone of tangling copy...
ReplyDD News Girls Delhi
Great Job I like You Post I have also written something on my website, You read it, you will like it. https://www.kavyamittal.com
Reply