Manuel Huber
Manuel Huber

Reputation: 121

Sonar rest API insufficient privileges

I can't access most of the Sonar API, for example

localhost:9000/api/tests/show?key=htmlparser:/src/test/java/HtmlParserTest.java

or see api/sources/scm. api/server/system and some other general stuff works but nothing where I actually see the code.
I always get a

{"errors":[{"msg":"Insufficient privileges"}]}

I set the project permissions to let anyone see source code & browse the porject, I tried it with Postman, a Java HttpRequest, the command line ...
curl -u admin:admin localhost:9000/api/tests/show?key=htmlparser:/src/test/java/HtmlParserTest.java
I checked with SonarQube 5.1 and 4.5.1. I've found a posts with the same issue but have yet to find a fix. Does anyone have a solution idea?
Thanks for your help

Upvotes: 1

Views: 2537

Answers (1)

Manuel Huber
Manuel Huber

Reputation: 121

SOLUTION
It was a syntax error (even though the message said Insufficient privileges). The correct call would be:

localhost:9000/api/tests/show?key=htmlparser:htmlparser:src/test/java/HtmlParserTest.java

If you are not sure what goes before the "src/..." don't worry. You can get it by calling api/projects/index and looking at the attribute named "k".

Upvotes: 1

Related Questions