1
Sonarqube webservice APIを使用しようとしています。私は、このWebサービスAPIにユーザー名とパスワードと共にいくつかのパラメータを渡す必要があります。私はこの次のコードを書かれているそのためにSonarqube webservice APIにアクセスできない
-
HttpClient client = new HttpClient();
String uri = "http://myUrl.sonar.com";
client.getState().setCredentials(new AuthScope(uri, 8080, AuthScope.ANY_REALM),
new UsernamePasswordCredentials("username", "password"));
GetMethod get = new GetMethod("http://myUrl.sonar.com/api/resources?"
+ "resource=110041&format=json&metrics=ncloc,coverage&verbose=true"
+ "&metrics=sqale_index,sqale_debt_ratio,ncloc,sqale_rating");
get.setDoAuthentication(true);
try {
int status = client.executeMethod(get);
System.out.println(status + "\n" + get.getResponseBodyAsString());
} catch (IOException e) {
e.printStackTrace();
} finally {
get.releaseConnection();
}
私は、Eclipseからこのコードを実行すると、それは
401
{"err_code":401,"err_msg":"Unauthorized"}
このための任意の可能性の理由を返しますか?ユーザー名とパスワードは正しいです。
権限は正しいですか? – CSchulz
プロジェクト110041に対して[参照]権限を持っていますか? –
@ JulienL.-SonarSourceTeam、私はソナーのウェブサイトからプロジェクトをブラウズしようとしましたが、うまくいきます。それ以外の場所を確認する必要はありますか? –