您好我一直在尝试通过bugzilla的rest api方法搜索bugzilla中的bug。为了得到错误,我在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);
}
答案 0 :(得分:0)
根据this Api doc,您可能在请求字符串中遗漏了某些内容。
至少你的URL url=new URL("http:mybugzilla.com/bug")
应该是
网址网址=新网址(" http://mybugzilla.com/bug")
答案 1 :(得分:0)
用python编写的示例示例,使用其余的API从Bugzilla 5.x获取公共错误列表。
import requests
url_bz_restapi = 'http://localhost/bugzilla/rest.cgi/bug'
r = requests.get(url_bz_restapi)