Skip to main content

SPFx web part to get data from Azure AD - Getting some values but not others

I have an SPFx web part and I wish to display the users within a group. I am trying to get their Display Name and other data (Email) but I get null for their Display Name. I do get data for their ID (GUID). thanks P (also including some warnings I get)

protected async getGroupData(): Promise<string> {
    console.log('getGroupData...');

    //const { context } = this.props;
    const client: MSGraphClientV3 = await this.context.msGraphClientFactory.getClient("3");
    const theADUsers: any = await client.api(`/groups/${"group guid"}/members/microsoft.graph.user`)
      .header('ConsistencyLevel', 'eventual')
      //.search('displayName:P')
      .select('displayName,id,mail,surname')
      .orderby('displayName')
      .get();

    console.log(theADUsers);

    return ""
}

odata.context : "https://graph.microsoft.com/v1.0/$metadata#users(displayName,id,mail,surname)" value : Array(15) 0 : displayName : null id : "4d76a6e0-etc" mail : null surname : null

Warning - lint - src/webparts/v2Test/V2TestWebPart.ts(8,10): error @typescript-eslint/no-unused-vars: 'escape' is defined but never used. Warning - lint - src/webparts/v2Test/V2TestWebPart.ts(50,18): error @typescript-eslint/no-explicit-any: Unexpected any. Specify a different type. Warning - lint - src/webparts/v2Test/V2TestWebPart.ts(53,5): error prefer-const: 'stringToReturn' is never reassigned. Use 'const' instead. Warning - lint - src/webparts/v2Test/V2TestWebPart.ts(72,23): error @typescript-eslint/no-explicit-any: Unexpected any. Specify a different type.

Pete Whelan
  • 109
  • 1
  • 4
  • 17