POST Method:
POST method is used to send data to a server to create/update a resource. The data sent to the server with this method is stored in the request body of the HTTP request.
REST ASSURED:
Rest Assured enables you to test REST APIs using java libraries and integrates well with Maven. It has very efficient matching techniques, so asserting your expected results is pretty straightforward. In addition, it has methods to fetch data from almost every part of the request and response no matter how complex the JSON structures are.
Advantages of Rest ASSURED are:
- Rest Assured is a group of java libraries that enables us to automate Rest API testing.
- It helps fetch values of requests and responses from complicated JSON structures
- The API request can be customized with a variety of header, query, path param, and any session or cookies to be set.
- It helps set assert statements and conditions.
- While Rest Assured is very helpful when the response is JSON type. Its methods may not work seamlessly if the content type is HTML or plain text.
Automation scripts for the POST Method using REST ASSURED are:
- First, we create a java maven project in IDE. Then add dependencies in the pom.xml file below are the dependencies we added are:

2. Then we create an ApiAutomation.java class and in that class declare a method for a POST request using REST ASSURED this is a POST request we also use the body to create a new request






3. After that we create a PostRequest.java class and call a method that we declare in an ApiAutomation.java class and run the test using @Test annotation . In addition, we will see if our test is passing or failing and we are also using assertion for that.






Likewise, we can create automation scripts of HTTP methods like GET, POST, PUT, DELETE, and many more using REST ASSURED . Also, we can use assertions to verify that.
References:


