Posts

Showing posts with the label POST Request

Automating POST Request using Rest Assured - Part 1

Image
In the previous post, we learned about how to install and configure the API Server on our local system. In this post, we learn to automate a POST request to API installed on our local system by sending a string in the body method.  Rest Assured supports all the HTTP methods like GET, POST, PUT and DELETE. Here GET stands for Read operation, POST stands for Write operation, PUT stands for Update operation and DELETE as the name suggests it stands for Delete operation. Now let's look at an example of POST Request using Rest Assured import org.testng.annotations.BeforeClass ; import org.testng.annotations.Test ; import io.restassured.RestAssured ; import io.restassured.http.ContentType ; import static io. restassured . RestAssured .*; public class PostRequestTest { @BeforeClass public void setBaseUri () { RestAssured. baseURI = "http://localhost:3000" ; } @Test public void postString () { given(). body ( ...

Automating POST Request using Rest Assured - Part 2

Image
In the previous post, we learned about automating a POST request by sending a string in the body method. In this post, we will focus on automating a POST request by sending an object in the body method instead of string. The reason behind sending an object in body method is that sending a string with large number of parameter can become tedious and updating a string having n number of parameters may become time consuming. Hence, it is always recommended to send an object in body method. Now lets look at an example of automating POST request using Rest Assured. public class Posts { public String id ; public String title ; public String author ; public void setId ( String id ) { this . id = id ; } public void setTitle ( String title ) { this . title = title ; } public void setAuthor ( String author ) { this . author = author ; } public String getId () { return id ; } public...

Popular posts from this blog

Using RequestSpecBuilder in Rest Assured ( Code Reuse )