I am trying to connect Bugzilla to java using j2bugzilla. But i can't login to Bugzilla via following code. response is {"version":"1.1","error":{"name":"JSONRPCError","message":"method is nothing.","code":100300}}. Can anyone point where the issue ?
static void callBugzilla() {
BugClass bugObj = new BugClass();
bugObj.setComponent("News Reader");
bugObj.setProduct("MR7");
bugObj.setSummary("this is a test summary");
bugObj.setVersion("1.0");
HttpParams httpParameters = new BasicHttpParams();
ConnManagerParams.setTimeout(httpParameters, 10000);
HttpConnectionParams.setConnectionTimeout(httpParameters, 10000);
// HttpConnectionParams.setSoTimeout(httpParameters,
// SO_TIMEOUT);
DefaultHttpClient httpclient1 = new DefaultHttpClient(httpParameters);
HttpPost httpPostRequest = new HttpPost(
"http://bugzilla.mycompanyname.org/bugzilla/jsonrpc.cgi?method=User.get&Bugzilla_login=login&[email protected]&Bugzilla_password=123456");
StringEntity entity = null;
try {
entity = new StringEntity(new Gson().toJson(bugObj));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println(new Gson().toJson(bugObj));
entity.setContentType("application/json");
// Set HTTP parameters
httpPostRequest.setEntity(entity);
System.out.println("entity:" + httpPostRequest.getEntity());
// Pass Profile to Server and collect response
String uploadResponse = null;
try {
HttpResponse resp = httpclient1.execute(httpPostRequest);
System.out.println("resp:" + resp.getStatusLine());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Use the following code to connect to the Bugzilla.
and meven dependency is