WebAPIv2: How to search for a group with exact name

Version: SonarQube 10.6.0
I have two user groups on SonarQube: heros, heros1.
Now I want to query only the heros group with an exact match to get the group-id for further API interaction.
According to documentation an exact match is possible.
The query http://localhost:9000/api/v2/authorizations/groups?q=heros returns both groups.
When I put heros under single or double quotation marks I get no result.
Also the regex pattern ^heros$ does not work.

What is necessary to get an exact match?

Thank you.

Hello @andi ,

Welcome to the community. The API doc mentions that searching by q param can either perform an exact match or a partial match (contains). So, in your case, this is performing a partial match.

I would suggest you iterate the result to match by group name and proceed.

Thanks,
Sarath

That in my case it does a partial match was obvious.
But is there any possibility to do an exact match, as the documentation implies?
Of course I could filter the results, but that would be a dirty solution.

Thanks, Andreas

Hello @andi,

I am sorry for the confusion with the API documentation. It says, can either perform an exact match or a partial match (contains). Well actually, it can only perform a partial match. I will fix the documentation and have created this ticket.

Cheers,
Sarath

The fix will be available in SonarQube v10.7.

As for doing an exact match, we will consider it if there’s a lot of interest among our users for this feature.

Thanks!

1 Like