0

When I convert JSON body to String via response.getBody().asString() it looses line breakers in JSON response. How can I keep them and display in console output?

If I use simple GET request to get some JSON data, it has beautified view

import io.restassured.RestAssured;
import io.restassured.http.Method;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import org.testng.annotations.Test;

public class Demo6_GET_AuthTest
{
    @Test
    public void AuthTest()
    {
       RestAssured.baseURI = "https://test.sideways6.com/api/";
       RequestSpecification httprequest = RestAssured.given();
       Response response = httprequest.request(Method.POST, "auth/login");

       String responseBody = response.getBody().asString();
       System.out.println(responseBody);
    }
}

sample of output

RamPrakash
  • 1,687
  • 3
  • 20
  • 25
Ip Man
  • 77
  • 10

1 Answers1

0

Printing asString will not beautify response,

Try System.out.println(response.then().log().all());