I have been experimenting with using the sonar web API as I have many projects to onboard and I would also like to extract metrics from the projects.
After some playing around I think I have most things working. There are two things that puzzle me which I am posting as separate questions / issues.
I can think of no sane reason for this. Is there one? Why is this API not allowed with the “browse projects” permission?
Is there an alternative API that is?
Without this API it is not possible, for example, to iterate over all projects and pull out metrics of interest like coverage or kloc. I should not need adminstrative privileges to do that.
Reverse engineering the API as per How to reverse engineer the Sonar Web API
I find that the user interface (which is obviously capable of listing projects without admin privileges) uses /api/components/search_projects
Thanks for the followup. You had marked this as solved and so we didn’t see the need for anything further.
Perhaps it helps to know that the Web API was crafted exclusively to the service of the UI. That’s why we advise eavesdropping on the UI to master the API. And, transparently, the only goal of the Web API is to draw the UI. If you get direct benefit from it too, that’s gravy.
To perhaps satisfy your curiosity, I believe the projects/search service you tried first was built to populate admin-level pages. Because it must be possible to perform global-level admin on a project even if you don’t have Browse on the project, that service doesn’t provide the same filtering the components/search_projects service you eventually found does. And that’s why the first one requires admin rights and the second one doesn’t. They have different functions for different purposes.
And I’ll forward this to the team in case they want to beef up the API docs. But I’m not going to hold my breath.
Ann
P.S. I’m going to un-mark this solved just so it doesn’t confuse anyone.