Skip to main content

Response Logging in REST Assured

In this one we are going to log the response. For request we log after given() for response we log after then(). You can log cookies, status, headers, body and all components at once. Check below example:

public class DummyRestAPIExample 
	public void setup()
		RestAssured.baseURI = "";
		RestAssured.basePath = "/api";
	public void postMethodExample()
			.body("{" + 
					"\"name\":\"Tarun Goswami\",\n" + 
					"\"job\":\"QA\",\n" + 
//			.cookies()
//			.headers()
//			.body()
//			.all()

Uncomment the component in above example which you want to log.

Submitted by tgoswami on September 2, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.