# Multiple Permission in single API call

**URL:** <https://community.sonarsource.com/t/multiple-permission-in-single-api-call/136611>\
**Category:** SonarQube Server / Community Build\
**Tags:** api, web\_api, sonarqube, scanner\
**Created:** [March 11, 2025, 10:08am UTC](https://community.sonarsource.com/t/multiple-permission-in-single-api-call/136611 "2025-03-11T10:08:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![YUGAN\_NITHISH\_KUMAR](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/yugan_nithish_kumar/32/64910_2.png) [@YUGAN\_NITHISH\_KUMAR](https://community.sonarsource.com/u/YUGAN_NITHISH_KUMAR)\
**Post date:** [March 11, 2025, 10:08am UTC](https://community.sonarsource.com/t/multiple-permission-in-single-api-call/136611/1 "2025-03-11T10:08:02Z")

</div>

Hello SonarQube Community, @Bachri_Abdel

I’m using the **SonarQube API** to add a group to multiple projects and assign **multiple permissions** to that group. However, when I run my script, it **only applies the first permission** (`issueadmin`) and ignores the rest.

#### **What I’m Trying to Do:**

- Assign a group to multiple projects.
- Grant the group **all six permissions** :
  - `issueadmin`, `securityhotspotadmin`, `scan`, `admin`, `user`, `codeviewer`

- Use the **`/api/permissions/add_group`** endpoint to assign each permission.

I know only one Permission per api call.  
I cant try the Permission Template becuase when i add the template it will overide the exsisitng permission and erase that and add the template i passed so , i cant go with template.

#### **Issue I’m Facing:**

- The API **only applies the first permission (`issueadmin`)** and does not add the rest.
- This happens even when I loop through each permission separately.
- There’s **no error returned from the API** —it just doesn’t apply the additional permissions.

```auto

import requests
import time
SONARQUBE_URL = "https://test.com"
AUTH_TOKEN = "testkey" 

PROJECT_KEYS = ["test_proj_key"]  

GROUP_NAMES = ["test group"] 

PERMISSIONS = ["issueadmin", "securityhotspotadmin", "scan", "admin","user", "codeviewer",]

API_URL = f"{SONARQUBE_URL}/api/permissions/add_group"

auth = (AUTH_TOKEN, "")

for project in PROJECT_KEYS:
    for group in GROUP_NAMES:
        for permission in PERMISSIONS:
            params = {
                "projectKey": project,
                "groupName": group,
                "permission": permission
            }
            
            response = requests.post(API_URL, auth=auth, params=params)
            
            if response.status_code == 204:
                print(f'Successfully added permission "{permission}" for group "{group}" to project "{project}".')
            else:
                print(f'Failed to add permission "{permission}" for group "{group}" to project "{project}". Status: {response.status_code}, Response: {response.text}')

```

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [March 12, 2025, 2:18pm UTC](https://community.sonarsource.com/t/multiple-permission-in-single-api-call/136611/2 "2025-03-12T14:18:12Z")

</div>

Hi,

Welcome to the community!

I invite you to familiarize yourself with the FAQ, and in particular, this section:

> ## [I created a topic, when can I expect a response?](https://community.sonarsource.com/faq#sla)
> 
> This is an open community with people volunteering their free time to provide assistance. We’re eager to contribute to the community, but you are not guaranteed a fast response.
> 
> ### [Be patient](https://community.sonarsource.com/faq#patient)
> 
> - Wait a few days before bumping a topic that hasn’t received a response.
> - Do not @name mention individuals not involved in the topic.

`@`-ing people not already involved in a topic does not move you to the top of their to-do list. Generally, just the opposite.

> [@YUGAN\_NITHISH\_KUMAR](#):
>
> - This happens even when I loop through each permission separately.
> - There’s **no error returned from the API** —it just doesn’t apply the additional permissions.

What _is_ returned?

&nbsp;  
Ann
