Add members using patch method does not add users to group
@shemogumbe 已經在處理了。
開始於 2024年8月29日。
評估
這個 Issue 還沒有評估資料。
描述
Title
Add members using patch method does not add users to group.
Environment
Python Version: 3.10.12
msgraph-sdk version: 1.1.0
OS: Ubuntu 22.04
Stack trace (if available) Screenshot or formatted copy and paste of your stack trace.
N/A
Describe the bug A clear and concise description of what the bug is.
I have the following methods to add a single and multiple users to a group in my AAD B2C tenant. The post method works, and the user is added to the AAD group. The patch method does not work, it returns None and does not raise any exception. I tried the same payload with my user Ids using the MS Graph explorer and users are added successfully. The service principal has full Group, GroupMember and User permissions in the MS Graph API.
async def add_group_member(group_id: str, user_id: str) -> bool:
"""Adds a single user to a group."""
try:
if not user_id:
return False
request_body = ReferenceCreate(odata_id = f'https://graph.microsoft.com/v1.0/directoryObjects/{user_id}')
await GRAPH_CLIENT.groups.by_group_id(group_id).members.ref.post(request_body)
return True
except Exception as e:
raise e
async def add_group_members(group_id: str, user_ids: List[str]) -> bool:
"""Adds users to a group."""
try:
if not user_ids:
return False
elif len(user_ids) > 20:
raise Exception("You can only add 20 users at a time.")
elif len(user_ids) == 1:
return await self.add_group_member(group_id, user_ids[0])
request_body = Group(
additional_data = {
"members@odata_bind" : [f'https://graph.microsoft.com/v1.0/directoryObjects/{user_id}' for user_id in user_ids]
}
)
await GRAPH_CLIENT.groups.by_group_id(group_id).patch(request_body)
return True
except Exception as e:
raise e
To Reproduce Steps to reproduce the behavior:
GRAPH_CLIENT = ClientSecretCredentials(...)
add_group_members(group_id, user_ids)
Expected behavior A clear and concise description of what you expected to happen.
Multiple groups added to the group in a single patch request.
Screenshots If applicable, add screenshots to help explain your problem.
N/A
Additional context Add any other context about the problem here.
N/A
- 主要語言
- Python
- 星號
- 630
- 分支
- 96
- 平均合併
- 15 小時 20 分鐘
- 30 天內合併 PR
- 3
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoftgraph/msgraph-sdk-python 的其他 Issue
-
status:waiting-for-triage type:bug
難度 1/5 1 小時以內 新手友好度 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
-
status:waiting-for-triage type:bug
難度 2/5 1-3 小時 新手友好度 75/100
microsoftgraph/msgraph-sdk-python#1563 ·
-
Needs: Attention :wave: type:bug
難度 2/5 1-3 小時 新手友好度 62/100
microsoftgraph/msgraph-sdk-python#1287 · 2 則留言 · 1 個 reaction ·
-
status:waiting-for-triage type:bug
難度 3/5 1-2 天 新手友好度 52/100
microsoftgraph/msgraph-sdk-python#1578 ·
-
status:waiting-for-triage
難度 5/5 一週以上 新手友好度 25/100
microsoftgraph/msgraph-sdk-python#1557 ·
查看 microsoftgraph/msgraph-sdk-python 的全部 Issue
相似的 Issue
-
essnmx good first issue
難度 1/5 1 小時以內 新手友好度 95/100
-
難度 2/5 1-3 小時 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 則留言 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未關閉area: repo bug perceived difficulty: 2
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
yeti-platform/yeti#1380 ·