2010-09-20 129 views
4

如何使用bugzilla rest api報告bug?以下文檔指出bug對象或其一些字段必須包含在POST主體中。我試圖添加字段作爲POST方法參數,但我得到這個錯誤「沒有數據提供創建」狀態代碼400.我的問題是,我怎麼能包括一個錯誤對象或其一些字段在POST方法體?如何使用Bugzilla REST API發佈bug

https://wiki.mozilla.org/Bugzilla:REST_API:Methods#Create_new_bug_.28.2Fbug_POST.29

String serverURL = "https://api-dev.bugzilla.mozilla.org/test/latest"; 
     String product = "FoodReplicator";    
     HttpClient client = new HttpClient(); 
     PostMethod method = new PostMethod(serverURL + "/[email protected]&password=123456); 
     method.addParameter("product", "FoodReplicator"); 
     method.addParameter("component", "Salt"); 
     method.addParameter("summary", "testing"); 
     method.addParameter("version", "1.0"); 
     client.executeMethod(method); 
     return method.getStatusCode() + " " + method.getResponseBodyAsString(); 

回答

2

您需要格式化您的數據,而不是JSON後則params的。創建的請求類型仍然是POST,但正文需要是JSON。