Post 邮递员给出了正确的响应,但对于相同的请求,restassured返回空?
正如您所看到的,邮递员返回了预期的结果 但是res.asString()在blow代码中给出了[],你能告诉我为什么吗Post 邮递员给出了正确的响应,但对于相同的请求,restassured返回空?,post,rest-assured,Post,Rest Assured,正如您所看到的,邮递员返回了预期的结果 但是res.asString()在blow代码中给出了[],你能告诉我为什么吗 def "simple test"(){ String url="http://xxx.xxx.xxx/assessment/api/Test.html" when:"" io.restassured.response.Response res=RestAssured.given().header("Content-Type", "applicati
def "simple test"(){
String url="http://xxx.xxx.xxx/assessment/api/Test.html"
when:""
io.restassured.response.Response res=RestAssured.given().header("Content-Type", "application/x-www-form-urlencoded").formParam("Action", "getDiagnosisList").formParam("Data", "[{\"subject\":\"冠心病\",\"option\":\"是\"}]").post(url)
then:""
res.prettyPrint()=="[\"身体健康状态不良\",\"医疗处置\"]"
}
也许通过邮递员发出的请求没有被缓存,另一方面,通过重启发出的相同请求正在使用某种缓存。最近我遇到了一个类似的问题,因为它击中了varnish服务器。我建议您查看来自postman和Restassed的响应标题。结果是,默认情况下,汉字无法正确编码,添加blow代码后,一切都按预期进行:
RestAssured.given().config(RestAssured.config().encoderConfig(EncoderConfig.encoderConfig().defaultContentCharset("UTF-8")))
,谢谢,我在不同的时间从不同的机器上尝试了多次,每次邮递员给我期望的结果,但重新发行时给出的是空的[]