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"} 

このための任意の可能性の理由を返しますか?ユーザー名とパスワードは正しいです。

+0

権限は正しいですか? – CSchulz

+1

プロジェクト110041に対して[参照]権限を持っていますか? –

+0

@ JulienL.-SonarSourceTeam、私はソナーのウェブサイトからプロジェクトをブラウズしようとしましたが、うまくいきます。それ以外の場所を確認する必要はありますか? –

答えて

0

あなたはそれを使用するために私たちのそのinいくつかの例を参照して、いくつかのURLを照会するために私たちのAPIを試してみてください:

、最後のバージョンは、ここに提供されています:http://search.maven.org/#artifactdetails%7Corg.sonarsource.sonarqube%7Csonar-ws%7C5.6%7Cjar

関連する問題