XzaR
XzaR

Reputation: 680

How do I filter and select inside a expanded collection on Microsoft Graph?

This code works

https://graph.microsoft.com:443/v1.0/me/drive/root?$filter=Size eq 0&$expand=children($select=id,folder,name,parentReference,cwebUrl)&$select=Id,folder,name,parentReference,children,webUrl

I want to filter inside the children:

https://graph.microsoft.com:443/v1.0/me/drive/root?$filter=Size eq 0&$expand=children($select=id,folder,name,parentReference,cwebUrl&$filter=Size eq 0)&$select=Id,folder,name,parentReference,children,webUrl

Upvotes: 15

Views: 24002

Answers (1)

TomDoesCode
TomDoesCode

Reputation: 3681

When filtering/selecting within an expand, you need to use ; as the separator, not &. So your URL should be:

https://graph.microsoft.com:443/v1.0/me/drive/root?$filter=Size eq 0&$expand=children($select=id,folder,name,parentReference,cwebUrl;$filter=Size eq 0)&$select=Id,folder,name,parentReference,children,webUrl

Here is an example of a URL on the TripPin example OData service to show this in action:

http://services.odata.org/V4/TripPinServiceRW/People?$expand=Trips($select=TripId,Name,Description;$filter=TripId eq 0)

Upvotes: 15

Related Questions