开发者

How to post a bug using Bugzilla REST API

How can I report a bug with bugzilla rest api? The following document states that the bug object or a some of its fields must be included in POST body. I have tried adding the fields as POST method parameters but i get this error "No data supplied for create" with status code 400. My question is that how can I include a bug object or some of its fields in开发者_开发问答 the POST method body??

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 + "/bug?username=abc@xyz.com&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();


You need to format your data as JSON instead of post params. The request type for create is still POST, but the body needs to be JSON.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜