Post 请放心-显示错误的请求
这是我的请求xml:Post 请放心-显示错误的请求,post,rest-assured,Post,Rest Assured,这是我的请求xml: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Request> <user> <title>Mr</title> <firstname>automation</firstname> <lastname>Qa</lastname>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Request>
<user>
<title>Mr</title>
<firstname>automation</firstname>
<lastname>Qa</lastname>
<department>Automation</department>
<mobile>999000777</mobile>
</user>
</Request>
String APIUrl = "http://autoTest.com/api/1/user/create";
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("title", "Mr");
hashMap.put("firstname", "automation");
hashMap.put("lastname", "testing");
hashMap.put("department", "test");
hashMap.put("mobile", "7878787");
Response response = RestAssured.given().auth().preemptive() .basic("userName", "passw0rd").
parameters(hashMap).when().post(APIUrl);
有人能帮我找出我做错了什么吗?您可能需要添加
contentType(“application/xml”)
,这样就可以放心地知道它应该将映射序列化为xml
Bad request ,
Request resource or xml is not valid ,
Sorry, we could not find appropriate method or xml.