We have a requirement to add members to azureAdGroup using users email through java spring boot application, we are using microsoft graph api rest call to add members to the azureAdGroup
Trying to add members to azureAdGroup by using the members email through java spring boot application,we are using the below code to add the members using the graph API
DirectoryObject directoryObject = new DirectoryObject();
directoryObject.id = "[email protected]"; // members emailId
graphClient.groups(adGroupId).members().references()
.buildRequest()
.post(directoryObject);
But we are getting the below error
CoreHttpProvider[sendRequestInternal] - 404Graph service exception Error code: Request_BadRequest CoreHttpProvider[sendRequestInternal] - 404Error message: Invalid object identifier '[email protected]'. CoreHttpProvider[sendRequestInternal] - 404 CoreHttpProvider[sendRequestInternal] - 404POST https://graph.microsoft.com/v1.0/groups/sgdbhjd-sndeh3h3-dasdnj3k3-dwb23/members/$ref CoreHttpProvider[sendRequestInternal] - 404SdkVersion : graph-java/v5.0.0 CoreHttpProvider[sendRequestInternal] - 404SdkVersion : graph-java/v5.0.0
Could anyone please help how to add member to a azureAdGroup using members email through microsoft graphApi from java spring boot application
Could anyone please help how to add member to a azureAdGroup using user email through microsoft graphApi from java spring boot application
For sample, I used Graph Explorer APIs to add the users to the group:
Passed the UPN of the user and got the error:
To resolve the error, pass the
ObjectIDof the user not the UPN:After passing the
ObjectID, user got added successfully to the group:Modify your code by passing the
ObjectIDof the user instead of UPN: