Can't add users to groups
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- azure, typescript
- Domain
- api
Research direction
Start with groups/item/members/ref/index.js and inspect RefRequestBuilderUriTemplate, comparing it with the request body and the reported '@id' error. Reproduce the group-member request against the stated SDK scenario and verify that adding the user succeeds without the workaround; check the generated request path before considering the issue done.
Written by the indexing model from the issue text.
Description
Describe the bug
I'm trying to add a user to a group as follows
export const addUserToGroup = async (userId: string, groupId: string) => {
try {
await client()
.groups.byGroupId(groupId)
.members.ref.post({
odataId: `https://graph.microsoft.com/v1.0/directoryObjects/${userId}`,
});
return true;
} catch (error) {
console.error('Error adding user to group:', error);
return false;
}
I get the following error
Error adding user to group: {
errorEscaped: {
code: 'Request_BadRequest',
message: "Unrecognized query argument specified: '@id'.",
innerError: {
date: 2025-11-09T12:25:07.000Z,
requestId: 'xxx',
clientRequestId: 'xxx'
}
},
message: "Unrecognized query argument specified: '@id'.",
responseStatusCode: 400,
responseHeaders: {
'client-request-id': [ 'xxx' ],
'content-encoding': [ 'gzip' ],
'content-type': [ 'application/json' ],
date: [ 'Sun', ' 09 Nov 2025 23:25:07 GMT' ],
'request-id': [ 'xxx' ],
'strict-transport-security': [ 'max-age=31536000' ],
'transfer-encoding': [ 'chunked' ],
vary: [ 'Accept-Encoding' ],
'x-ms-ags-diagnostic': [
'{"ServerInfo":{"DataCenter":"Australia East"',
'"Slice":"E"',
'"Ring":"5"',
'"ScaleUnit":"000"',
'"RoleInstance":"xxx"}}'
]
}
}
Expected behavior
The user is added to the group
How to reproduce
Use the code above.
NOTE: This for Azure AD B2C in case it matters
SDK Version
1.0.0-preview.74
Latest version known to work for scenario above?
Has never worked
Known Workarounds
This patch works around it
diff --git a/groups/item/members/ref/index.js b/groups/item/members/ref/index.js
index 9e8a14654fab3754b01311e07c9bd79d2569d5ca..0d396bdf8da2bf273686abbcb08fae6d581682dd 100644
--- a/groups/item/members/ref/index.js
+++ b/groups/item/members/ref/index.js
@@ -8,7 +8,7 @@ import { createODataErrorFromDiscriminatorValue } from '@microsoft/msgraph-sdk/m
/**
* Uri template for the request builder.
*/
-export const RefRequestBuilderUriTemplate = "{+baseurl}/groups/{group%2Did}/members/$ref?@id={%40id}{&%24count,%24filter,%24orderby,%24search,%24skip,%24top}";
+export const RefRequestBuilderUriTemplate = "{+baseurl}/groups/{group%2Did}/members/$ref?{&%24count,%24filter,%24orderby,%24search,%24skip,%24top}";
/**
* Mapper for query parameters from symbol name to serialization name represented as a constant.
*/
Other information
I'm happy to generate a PR with the above if the fix is sensible.
I'm also new to the API so it's possible my code is not taking the right approach
- Dominant language
- TypeScript
- Stars
- 44
- Forks
- 7
- Avg merge
- 12h 40m
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoftgraph/msgraph-sdk-typescript
-
status:waiting-for-triage ToTriage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoftgraph/msgraph-sdk-typescript#974 · 1 comment ·
-
status:waiting-for-triage ToTriage type:bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
microsoftgraph/msgraph-sdk-typescript#953 · 1 comment · 1 reaction ·
-
status:waiting-for-triage ToTriage
Difficulty 5/5 Over a week Newbie friendliness 25/100
microsoftgraph/msgraph-sdk-typescript#912 · 1 comment ·
-
status:waiting-for-triage ToTriage type:feature
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
status:waiting-for-triage ToTriage type:feature
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in microsoftgraph/msgraph-sdk-typescript
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·