Search code examples
apisonarqubehttp-status-code-403

SonarQube api api/project_analyses/search fails with 403 "msg": "Insufficient privileges" yet API key user is admin


I am accessing the SonarQube API through API key as described in https://docs.sonarqube.org/latest/extension-guide/web-api/

  • A call to /api/components/search_projects works.
  • A call to /api/project_analyses/search?project=PJ fails with http error code 403

If I log into the web interface with that user, I can browse the statistics. In fact Chromes F12 debug shows that it's calling the same api function /api/project_analyses/search yet with session cookie, xrfs-token etc. and the call succeeds.

What am I missing to be able to retrieve project statistics through the API?


Solution

  • The token used is created by the user which has sufficient permission for the project PJ

    You need to check the permission and generate new token accordingly.