Query parameter COUNT is not supported along with EXPAND?

Madhura Lodam 1 Reputation point
2022-12-19T13:58:40.807+00:00

When I use $expand query parameter along with $count, count is not supported in Graph api?

https://graph.microsoft.com/v1.0/applications?$count=true&$expand=owners

$count doesn't work even if I change the order like put $expand first and put $count next.

Can someone please shed some light if there is a way I can get the count after expanding the root elements?

Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,677 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 48,656 Reputation points
    2022-12-19T15:42:44.51+00:00

    As discussed here, you cannot use $expand in advanced queries currently. Furthermore $count is only supported on some directory objects (such as applications) currently and only in advanced queries. Therefore, based upon the docs, you cannot currently combine $count and $expand on the same call for applications.


  2. Srinivasa Rao Darna 6,696 Reputation points Microsoft Vendor
    2022-12-19T15:46:33.77+00:00

    Hello @Madhura Lodam ,

    $count=true in Azure AD Graph APIs are using in combination with ConsistencyLevel: eventual header with Advanced query capabilities on Azure AD directory objects along with $seach or specific $filter.

    You can refer to this example to get a count of applications.

    GET https://graph.microsoft.com/v1.0/applications/$count  
    ConsistencyLevel: eventual  
    

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments