0

Am new to API testing. I wanted to validated the response body of the GET method. But it is returning the io.restassured.internal.RestAssuredResponseImpl@35adf623 with the below code. Please let me know how can I resolve this. With POST Method, it works fine. Failing with GET method provided am passing all other values correct.

    public static Response getResponseWithGetMethod() throws Exception {
    Response response = RequestInvoker.invokeGET();
    return response;
}

Output :

io.restassured.internal.RestAssuredResponseImpl@35adf623

Expected output is :

 {
"path1": true,
"path2": true,
"path3": true
}
Rahul
  • 759
  • 3
  • 21
  • 43
  • what you've got is an object. Either jsonify the ```response``` or add a ```toString()``` method to your object (provided you wrote that class which seems unlikely) – user728627 Oct 30 '20 at 13:14

2 Answers2

0

Use the body() method to get access to the body of the response.

AZWN
  • 158
  • 12
0

Response object has multiple fields in it like, body, headers, status code, cookies etc., Check out the complete java doc here.

Answer to your code is to call getResponseWithGetMethod().body() or getResponseWithGetMethod().asString(); later one might be appropriate for you.

Venkatesh Laguduva
  • 13,448
  • 6
  • 33
  • 45