How can I get the list of email groups those are only visible in Global Address List using Graph API?

Viewed 95

I'm currently working on migrating from EWS to Graph API due to the first's soon shutdown. We had some logics to get all the email groups from our Outlook Global Address List.

Now when it's done using Graph API I have a problem with extra email groups in response (there are also our service groups, etc., those are hidden from GAL). My first approach was to select the HideFromAddressLists or HideFromOutlookClients properties and filter out the list by them as it's written in Microsoft's official dev blog announcement.

var response = graphServiceClient.Groups
    .Request()
    .Select("hideFromAddressLists")
    .GetAsync()

But all the requests with the usage of those two props fail with NotImplemented. enter image description here

Also when I'm trying to run the same request from the Microsoft's Graph Explorer it also fails with the same. enter image description here

Visibility and GroupTypes properties don't work for me, because they don't affect whether you can see the group on GAL or not. Also, I'm sure the issue is not with permissions because we've tried different combinations as Group.Read.All, GroupMember.Read.All, etc.

So how can I filter out the groups not visible in Outlook's GAL or is there any other Graph request that would help me?

1 Answers

Currently it is only available on the individual Group endpoint not the Groups collection so a request to

https://graph.microsoft.com/v1.0/Groups('938383f7-3060-4604-b3a5-cbdb0a5fc90f')/?$select=displayName,description,hideFromAddressLists

will work okay but

    https://graph.microsoft.com/v1.0/Groups?$select=displayName,description,hideFromAddressLists

will fail. Depending on the number of groups your trying to process you can batch the request in lots of 20 eg

{
"requests": [{
"id": "1",
"method": "GET","url": "/Groups('02aae12f-4db4-45e5-98e9-186ed42f6e10')/?$select=displayName,description,groupTypes,id,mail,mailEnabled,mailNickname,proxyAddresses,resourceProvisioningOptions,securityEnabled,visablity,hideFromAddressLists"
 },
{
"id": "2",
"method": "GET","url": "/Groups('148531b1-e9a7-471c-b8af-20213c0c55f2')/?$select=displayName,description,groupTypes,id,mail,mailEnabled,mailNickname,proxyAddresses,resourceProvisioningOptions,securityEnabled,visablity,hideFromAddressLists"
 },
{
"id": "3",
"method": "GET","url": "/Groups('233980f1-e71f-434a-ae24-bee9269dd2b4')/?$select=displayName,description,groupTypes,id,mail,mailEnabled,mailNickname,proxyAddresses,resourceProvisioningOptions,securityEnabled,visablity,hideFromAddressLists"
 }
]
}

That said it looks like its buggy at the moment on some groups requesting that property for me returns and error MailboxNotEnabledForRESTAPI (on valid groups) . The error isn't valid for the Operation so I would say they have some code issues...

HideFromOutlookClients you should be able to get in the resourceBehaviorOptions on a normal Group query

Related