I am accessing the SonarQube API through API key as described in https://docs.sonarqube.org/latest/extension-guide/web-api/
/api/project_analyses/search?project=PJ
fails with http error code 403If 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?
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.