How to post a bug using the Bugzilla REST API

How can I report a bug with bugzilla rest api? The following document states that the error object or some of its fields should be included in the POST body. I tried to add fields as parameters of the POST method, but I get this error "There is no data to create" with a status code of 400. My question is, how can I include an error object or some of its fields in the body of the POST method?

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(); 
+4
source share
1 answer

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

+2
source

All Articles