JSONRPCError:用于登录的Java Bugzilla集成并提交错误

时间:2013-12-13 12:54:58

标签: java bugzilla

  

我正在尝试使用j2bugzilla将Bugzilla连接到java。但我不能   通过以下代码登录Bugzilla。回应是    {“version”:“1.1”,“error”:{“name”:“JSONRPCError”,“message”:“方法无效。”,“代码”:100300}} 。任何人都可以指出问题所在吗?

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&Bugzilla_userName=abcd.kg@companyname.in&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 个答案:

答案 0 :(得分:0)

使用以下代码连接到Bugzilla。

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

和meven依赖是

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