java - 我如何使用 bugzilla rest api 方法/bug 列出错误

标签 java rest bugzilla

嗨,我一直在尝试通过 bugzilla 的 REST API 方法来搜索 bugzilla 中的错误。为了解决这些错误,我用 java 开发了代码,该代码给出了 406 错误。下面是我的代码。

public static void main(String[] args) throws IOException, JsonParser.ParseException,   
JSONException, ParseException {
  URL url=new URL("http:mybugzilla.com/bug");

  HttpURLConnection urlConnection= (HttpURLConnection) url.openConnection();
     urlConnection.setRequestProperty("Accept","application/json");
     urlConnection.setRequestMethod("GET");
     urlConnection.setDoOutput(true);
     urlConnection.connect();
     PrintStream printStream=new PrintStream(urlConnection.getOutputStream());
     //printStream.print();
     BufferedReader br = new BufferedReader(new      
     InputStreamReader(urlConnection.getInputStream()));

     String line;
     StringBuilder sb=new StringBuilder();
     while ((line = br.readLine()) != null) {
            sb.append(line).append("\n");

     }

     System.out.println(sb);
}

最佳答案

根据this Api doc您的请求字符串中可能缺少某些内容。 至少您的 URL url=new URL("http:mybugzilla.com/bug") 应该是

URL url=new URL("http://mybugzilla.com/bug")

关于java - 我如何使用 bugzilla rest api 方法/bug 列出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24279389/

相关文章:

java - 未创建 Log4j 文件 : logging from the application running on WAS6. 1

Java 枚举声明包含成员和方法

javascript - 如何使用 JSON 从 REST API 选择的对象中检索值?

linux - bash : ./checksetup.pl:没有这样的文件或目录

java - 如何从 HandlerInterceptorAdapter 检索 modelAttribute

java - JInput "no jinput-dx8 in java.library.path"错误

java - 用于传递错误消息的索引参数的 REST API

python - Django Rest Framework 中外键字段的动态选择

eclipse - 谁能帮我安装Eclipse Bugzilla插件?

rest - Bugzilla rest api 激活