Request Logging in REST Assured

If you want to identify some issue in Request you can use request logging. Request logging can be done for headers, cookies, uri, request method, parameters as well as body. You can log each thing separately or all at once using .all().


public class DummyRestAPIExample 
	public void setup()
		RestAssured.baseURI = "";
		RestAssured.basePath = "/api/v1";
	public void postMethodExample()
		Response res = 
//			.cookies()
//			.headers()
//			.body()
//			.parameters()
//			.method()
//			.uri()
			.body("{" + 
					"\"name\":\"test\",\n" + 
					"\"salary\":\"123\",\n" + 
					"\"age\":\"23\"\n" + 

Remove the comment to print log for each individual entity like cookies, headers etc. .all() will print logs for all.

Wed, 09/02/2020 - 04:30
Tarun Goswami is a highly experienced professional, currently serving as Technical Lead at a well-established IT services company. With over 12 years of experience across multiple domains, he demonstrates his expertise and passion for the industry through his engaging and informative blog writing in his spare time.