Matthieu Maitre
Matthieu Maitre

Reputation: 522

Microsoft Graph Group query does not expand relationships when $select is present

I am trying to query group owners along with a few properties of the groups. When I add $select the owners property gets dropped. I need $select to reduce the amount of data returned. Any way to achieve both?

/beta/groups?$expand=owners&$filter=startswith(mailNickname, 'rtan')&$top=999&$select=mailEnabled,owners

Response (has mailEnabled but is missing owners):

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(mailEnabled,owners)",
  "value": [
    {
      "mailEnabled": true
    },
    {
      "mailEnabled": true
    },
    {
      "mailEnabled": true
    }
  ]
}

Upvotes: 1

Views: 1535

Answers (2)

Dan Kershaw - MSFT
Dan Kershaw - MSFT

Reputation: 5838

Thanks @Matthieu for pointing this out. If you try the query without $select you'll see that the expansion does work. This issue is one of our documented known issues. I'm not saying that doesn't make things better — clearly in this case $select and $expand in the same request should just work.

Also @Marc points out, it's either or, but this isn't just a groups issue. It's across the board for all directory based entity types (users, groups, devices, applications, service principals, etc).

I don't have an ETA for a fix I'm afraid, but it is something that is being worked on.

Upvotes: 1

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59368

One workaround at the moment to combine both $select and $expand for /groups endpoint would be to specify asterisk (*) character in $select expression.

For example, the following query:

https://graph.microsoft.com/beta/groups?expand=owners&select=owners,*

will return all the group details along with owners

Upvotes: 1

Related Questions