Jur*_*urn 10 java rest-assured
我从 RestAssured 呼叫中收到 ContentType 响应text/plain;charset=UTF-8。我搜索了互联网,但无法找到一种很好的方法来从消息中获取内容,因为使用下面的方法不太好;
String content = response.then().extract().body().htmlPath().get().children().get(0).toString();
Run Code Online (Sandbox Code Playgroud)
如何更好地提取此响应的内容?
小智 14
您可以直接使用 .asString() 来获取响应的正文内容,而不管此返回 Content-Type 是什么。
你可以尝试这样的事情:
response.then().extract().body().asString();
Run Code Online (Sandbox Code Playgroud)
或直接:
response.asString();
Run Code Online (Sandbox Code Playgroud)