JSONRPCError : Java Bugzilla integration for login and file a bug

438 Views Asked by At

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();
        }


    }
1

There are 1 best solutions below

1
On

Use the following code to connect to the Bugzilla.

 BugzillaConnector conn = new BugzillaConnector();
 conn.connectTo("http://bugzilla.mycompanyname.org/bugzilla/", "userName", "password");
 LogIn logIn = new LogIn("userName", "password");
 conn.executeMethod(logIn);

and meven dependency is

<dependency>
    <groupId>com.j2bugzilla</groupId>
    <artifactId>j2bugzilla</artifactId>
    <version>2.2</version>
</dependency>