Get group members with MS Graph?

Regular Contributor

Hi,

I am trying to get the list of members of a specific group but I am getting nothing.

 

This is how I am making the call: 

public componentDidMount(): void {
this.props.graphClient
.api('v1.0/groups/9510878a-bbe4-4279-bcb0-0355250ca457/members')
.get((error: any, user: MicrosoftGraph.User, rawResponse?: any ) => {
this.setState({
name: user.displayName,
email: user.mail,
phone: user.businessPhones[0]
});
});
console.log(this.state);
}

At this point the state is completly empty: 

 {name: "", email: "", phone: "", image: null}
         email: ""
         image: null
         name: ""
         phone: ""

Obviously I am making a misstake in the componentDidMount() but I can't understand what is the error? 

 

Best regards

Americo

3 Replies

Are you looking to use MS Graph API to get members in a given Office 365 group? If yes, then you can try this.


1) First get the group id of the group
2) Second use the following API call to get the list of group members in it.

 

GET https://graph.microsoft.com/v1.0/groups/{id}/members

Hope this helps. 

I would suggest you first test the query in the Graph Explorer. 

 

https://developer.microsoft.com/graph/graph-explorer/ 

Hi,

Thanks but I am actually interested in team sites members, which users belong to a Team site

 

Regards

www.000webhost.com