[英]How to get response body of GET call in RestAPI?
我是 API 测试的新手。 我想验证 GET 方法的响应主体。 但它使用以下代码返回 io.restassured.internal.RestAssuredResponseImpl@35adf623 。 请让我知道我该如何解决这个问题。 使用 POST 方法,它工作正常。 提供的 GET 方法失败正在传递所有其他正确的值。
public static Response getResponseWithGetMethod() throws Exception {
Response response = RequestInvoker.invokeGET();
return response;
}
输出 :
io.restassured.internal.RestAssuredResponseImpl@35adf623
预期输出是:
{
"path1": true,
"path2": true,
"path3": true
}
使用body()
方法来访问响应的正文。
响应对象中有多个字段,如正文、标题、状态代码、cookie 等,请在此处查看完整的 java 文档。
您的代码的答案是调用getResponseWithGetMethod().body()
或getResponseWithGetMethod().asString()
; 以后可能适合你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.