2016-03-08 44 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。