2016-03-08 84 views
0

这里是我的请求XML:放心 - 显示错误的请求

<?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); 

当我做这个调用它的给我以下种类的控制台错误:

Bad request , 
Request resource or xml is not valid , 
Sorry, we could not find appropriate method or xml. 

任何人都可以帮助我找到我做错了什么?

回答

0

您可能需要添加contentType("application/xml"),这样才能放心地知道它应该将映射序列化为XML。