Skip to content

Instantly share code, notes, and snippets.

@maisarissi
Last active January 16, 2024 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maisarissi/50d075d2d44a114eb4420f298ff50ceb to your computer and use it in GitHub Desktop.
Save maisarissi/50d075d2d44a114eb4420f298ff50ceb to your computer and use it in GitHub Desktop.
microsoftgraph-java-v6-odata-cast
//Fetching the members of a group who are of the type User
//graph.microsoft.com/v1.0/groups/{group-id}/members/microsoft.graph.user
UserCollectionResponse usersInGroup = graphClient
.groups()
.byGroupId("group-id")
.members()
.graphUser()
.get();
List<User> users = usersInGroup.getValue();
//Similarly, members of the group of type ServicePrincipal
//graph.microsoft.com/v1.0/groups/{group-id}/members/microsoft.graph.servicePrincipal
ServicePrincipalCollectionResponse servicePrincipalsInGroup = graphClient
.groups()
.byGroupId("group-id")
.members()
.graphServicePrincipal()
.get();
List<ServicePrincipal> servicePrincipals = servicePrincipalsInGroup.getValue();
@MohamedSalahSayed
Copy link

Hi,
I am getting errors when using
.members().graphUser()

the graphUser() is not available in the return value of members().

Can you please show us the dependencies you used?
thanks

@maisarissi
Copy link
Author

Hi @MohamedSalahSayed . I'm using the Release Candidate (RC) version of the new Microsoft Graph Java v6 version. You can find more info here: https://devblogs.microsoft.com/microsoft365dev/write-simpler-faster-code-with-the-new-microsoft-graph-java-sdk-v6/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment