我正在使用路径 para 和查询 para 测试端点,并使用一些参数更新请求。当我发送请求内容类型是 json 并且请求看起来很好与我试图更改的数据但是当收到响应时
内容类型是文本,我收到 400 错误错误请求作为状态代码和错误消息
javax.ws.rs.ProcessingException:RESTEASY008200:JSON 绑定反序列化错误:javax.json.bind.JsonbException:无法推断解组类型:java.util.List
我的代码
@Given("^api is set up with required details$")
public void api_is_set_up_with_user_data() throws Throwable {
loadProp();
base_url = prop.getProperty("baseurl");
RestAssured.baseURI = base_url;
}
@When("^a user retrieves the preferences by userid \"([^\"]*)\" and type \"([^\"]*)\"$")
public void a_user_retrieves_the_preferences_by_userid_and_type(String userid, String parameter) throws Throwable {
request = given().pathParam("user_id", userid).queryParam("type", parameter);
System.out.println(request);
ENDPOINT_GET_USER_BY_ID = base_url + "{user_id}/preferences";
response = request.when().get(ENDPOINT_GET_USER_BY_ID);
System.out.println("response: " + response.prettyPrint());
}
@Then("^updates the value \"([^\"]*)\" of name \"([^\"]*)\"$")
public void updates_the_value_of_name(String value, String displaytext) throws Throwable {
HashMap<String,String> post = new HashMap<String,String>();
post.put("displaytext",displaytext);
post.put("value",value);
response = request.contentType("application/json").accept("*/*").body(post).put(ENDPOINT_GET_USER_BY_ID);
// response = request.header("Content-Type", "application/json").body(post).put(ENDPOINT_GET_USER_BY_ID);
System.out.println("Response : " + response.asString());
System.out.println("Statuscode : " +response.getStatusCode());
}
不负相思意
相关分类