当放心 url 具有自定义编码时没有响应



我正在使用rest-sursure来测试REST API,当点击url时,url有自己的编码参数。

 Response b = given().
                relaxedHTTPSValidation().body(gbody).
                with().
                contentType(ConfigReader.get("application.json")).
                then()
                .post(url);

它已成功运行,但响应为空。

请告诉可能是什么原因

这是因为,放心会在你对url进行编码时对url进行编码,需要使用方法urlEncodingEnabled(false),这样,它就不会再对url进行编码了。

现在你的代码将变成

Response res = given()
                .urlEncodingEnabled(false)
                .relaxedHTTPSValidation()
                .body(gbody)
                .with()
                .contentType(ConfigReader.get("application.json"))
                .then()
                .post(url);

最新更新