Trying to provide permission for project as project admin over API

Hi all

I’m using SonarQube version 9.9.3 LTS.
I created a user in SonarQube and a user token. This user is an administrator for the SonarQube project “my-analysis”. To provide additional user access to this project I try to use an API call like following:

curl -X POST -H "Content-Type: application/json" -u squ_123: https://sonarqube-dev.europe.axa-cloud.com/api/permissions/add_user?login=on-other-user&permission=issueadmin&projectKey=my-analysis

The output is always >{"errors":[{"msg":"Insufficient privileges"}]}

Do you have any hint why the administrator of the SonarQube project not can provide the permissions?
When I log in with this user, I can set the permissions over the WebUI

Thank you in advance
Best regards
Raphael

Hi Raphael,

Have you tried this via the UI? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

You may also find this guide helpful.

 
HTH,
Ann

Hi Ann
Thank you very much for your reply. Yes, I tested it with that user over the WebUI and it could do the action, like I mentioned in my first post.
Also other API calles are working with this user, but granting permission on for the SonarQube project is not working.
Maybe I read the documentation about the API wrongly.
Thank you for your response
Best regards
Raphael

Hi Raphael,

What I’m suggesting is that you do that once through the UI so see what calls the UI makes. You can then replicate them in your scripting, &etc as needed.

 
HTH,
Ann

Hi Ann
I tried your steps, but I came to the same result.
Now I tried to add double quotes at the beginning and end of the URL and now the command is working.
Thank you for help as always.
Best regards
Raphael

1 Like