We have a SharePoint integration that's partially working. We're able to create/save, delete and retrieve specific files via SharePoint's SearchDocumentsListItems method and a full URL reference path and file name. What we can't do is retrieve a list of files from a specific subdirectory.
The SharePoint site has a base of "/sites/<OurSiteName>/Shared Documents/Clients". The clients folder has over 10,000 subfolders and from there we have over one million subfolders and files. Yes, one million!
The relative path is the full path name to the folder is "/sites/<OurSiteName>/Shared Documents/Clients/<customer name>\COBRA\COBRA Participants\John Q Public" The advanced filter works fine with "FileRef eq '" + GetRelativePath.RelativePath + "/<file name>'. However, it will not work otherwise. I've tried:
All get the same error: "The attempted operation is prohibited because it exceeds the list view threshold"
I'm looking for an alternative method for getting a list of files in a SharePoint folder when we have so many files and folders. I need the list to include the SharePoint file ID so it can then be retrieved.
Any ideas?
Thanks in advance.
The threshold error suggests that SearchDocumentsListItems is not the best fit for listing files in a folder in such a large document library. Even with FileDirRef pointing to one folder, SharePoint may still process it as a list-item search over the document library, which can hit the List View Threshold when the library contains a very large number of items.
You may want to try the SharePoint REST folder endpoint instead, for example:
GET /sites//_api/web/GetFolderByServerRelativeUrl('/sites//Shared Documents/Clients//COBRA/COBRA Participants/John Q Public')/Files?$expand=ListItemAllFields
This asks SharePoint for the files in that specific folder directly, rather than filtering the whole document library by FileDirRef.
You can find discussion on GetFolderByServerRelativeUrl at : https://www.outsystems.com/forums/discussion/56388/has-anyone-successfully-created-a-rest-api-to-create-a-folder-on-sharepoint/