邮递员给出了正确的响应,但放心 returns 对同一请求为空?

Postman gives right response,but restassured returns empty for same request?

如你所见,邮递员 returns 预期结果

但是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", "application/x-www-form-urlencoded").formParam("Action", "getDiagnosisList").formParam("Data", "[{\"subject\":\"冠心病\",\"option\":\"是\"}]").post(url)

    then:""
    res.prettyPrint()=="[\"身体健康状态不良\",\"医疗处置\"]"
}

也许通过 postman 发出的请求没有被缓存,另一方面,通过 restassured 发出的相同请求正在使用某种缓存。最近我遇到了类似的问题,因为它正在攻击清漆服务器。我建议你看看邮递员和安心的回复headers。

原来汉字默认是不能正确编码的,加上blow代码后一切正常:

 RestAssured.given().config(RestAssured.config().encoderConfig(EncoderConfig.encoderConfig().defaultContentCharset("UTF-8")))