2010-09-20 131 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。