1 回答
TA贡献1871条经验 获得超8个赞
您需要在 RestAssured 请求中启用编码并使用queryParam(String, String)方法传递参数:
RestAssured.baseURI = "https://servicenowAPIadd.com";
RestAssured
.given()
.urlEncodingEnabled(true) //Encoding should be enabled by default anyway
.queryParam("sysparm_display_value", "true")
.queryParam("sysparm_query", "col_updated_on>=2017-09-30")
.when()
.get("/api/now/table/" + tableName);
如果您需要在另一个地方生成整个 url,请尝试使用URLEncoder(但您还应该在 RestAssured 中禁用 URL 编码以防止双重编码):
String dateParams = "sysparm_query=" + URLEncoder.encode("col_updated_on>=2017-09-30", "UTF-8"); //Encode your query params here
String uri = "https://servicenowAPIadd.com/api/now/table?" + dateParams;
RestAssured
.given()
.urlEncodingEnabled(false)
.get(uri);
添加回答
举报