tags:

views:

43

answers:

1

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 + "/[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();
A: 

I found out that the Bug object must be supplied as JSON object as that's the only language that the bugzilla REST api understands. But I'm still unable to post a bug like this... Now I get "Bad Request" with status code 400. Please help...

DefaultHttpClient httpClient = new DefaultHttpClient();

        BugzillaBugVO bug = new BugzillaBugVO();
        bug.setProduct("WorldControl");
        bug.setComponent("EconomicControl");
        bug.setSummary("nabeel");
        bug.setVersion(1.0);

        Gson gson = new Gson();

        HttpPost post = new HttpPost("https://api-dev.bugzilla.mozilla.org/test/latest/[email protected]&password=123456");
        post.setHeader("Content-Type", "application/json");
        post.setEntity(new StringEntity(gson.toJson(bug), "UTF-8"));

        ResponseHandler<String> responseHandler = new BasicResponseHandler();

        String response = httpClient.execute(post, responseHandler);
Nabeel