Repository navigation
Open
Labels
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
Activity
gavinbarron commentedon Nov 25, 2025
Thanks for raising this John Ferlito (@johnf)
Raising a PR to change that wouldn't really help as that code is generated from the specification that we have for Microsoft Graph using kiota
The invalid URI Template was introduced in bf57e0d
Tracing it back, we use a single UrlTemplate per request builder that represents all of the requests for a given path segment. The changes made in microsoft/kiota#3989 made the required
@idparameter for the delete a required part for all the requests and broke the POST operation here.I'm transferring this to the kiota repo as that's where the fix needs to happen.
This will be impacting all languages :|
gavinbarron commentedon Nov 25, 2025
Ahh shoot, can't do a cross org transfer... Opening an issue there...
johnf commentedon Dec 10, 2025
Gavin Barron (@gavinbarron) Did you end up opening the other issue? I had a quick look but couldn't find it.
gavinbarron commentedon Jan 14, 2026
John Ferlito (@johnf) microsoft/kiota#7292
Zamiell commentedon May 3, 2026
Gavin Barron (@gavinbarron) The linked issue from your last reply was closed - should we close this issue as well?
ianyong commentedon Aug 7, 2026
I can confirm that this issue has been resolved with the release of v1.0.0-preview.85 on 2026-07-10. Relevant commit with the fix: 3594b83#diff-2d4a6d41301c032269bea4cca12d9e53d9f9033fba509974e82ac108c60b0b79R99