Forum Discussion

NShivaBarath's avatar
NShivaBarath
Copper Contributor
Jan 08, 2023

Issue in formulating the Filter for SharePoint using Microsoft Graph API

I am trying to use the filter to get all the Folders within a specific Document Library.
The following throws error saying that 

Microsoft.Graph.ServiceException
HResult=0x80131500
Message=Code: BadRequest
Message: Invalid filter clause
var taskSearch = graphClient.Sites[site.Id].Lists["NameOfDocumentlibrary"].Items.Request().Filter("ContentType/any(i:i/Name eq Folder").GetAsync();
            var searchResult = taskSearch.GetAwaiter().GetResult();

The following returns all the items within the Document Library without any error:

var taskSearch = graphClient.Sites[site.Id].Lists["NameOfTheDocumentLibrary"].Items.Request().GetAsync();

Please advise on this.
Thanks

Resources