SharePoint 2013 Office 365 REST api - filter by FileDirRef

Hi,

We are using following REST call to query items from a document library and filter by FileDirRef. When we include the filter for FileDirRef, no items are returned from Office 365 sites. The same call/filter works fine on a local SharePoint 2013 box.

https://xxx.sharepoint.com/sites/abc/_api/web/lists/getbytitle('DocumentLibrary')/items?$Select=FileDirRef,FileLeafRef&$filter=startswith(FileDirRef, '/sites/abc/DocumentLibrary/folder1')

Why is filter by FileDirRef not working in Office 365 sites? Are we missing anything ?

Thanks

September 30th, 2014 7:17pm

Hi Sandhya,

What is your goal?

If you want to use RESET API to get files in a folder of a document library, I suggest you use http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files.

More information about working with folders and files with REST, please refer to the link:

http://msdn.microsoft.com/en-us/library/office/dn292553(v=office.15).aspx

In addition, this forum supports for SharePoint 2013 On-premises, for your issue, I suggest you create a new thread on Office 365 forum, more experts will assist you with Office 365.

Office 365 forum:

http://community.office365.com/en-us/f/default.aspx

Best Regards,

Wendy

Free Windows Admin Tool Kit Click here and download it now
October 1st, 2014 7:18am

Hi Wendy,

Thank you.

I am trying to get all files from a folder and its sub-folders of a document library. The api GetFolderByServerRelativeUrl do not retrieve files from containing sub-folders.

As suggested, I will post a new thread on Office 365 forum.

October 1st, 2014 10:15pm

Hi Sandhya,

For getting files in a subfolder, you can use:

http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name/subfolder')/Files

Best Regards,

Wendy

Free Windows Admin Tool Kit Click here and download it now
October 2nd, 2014 3:06am

I am sorry, but /_api/web/GetFolderByServerRelativeUrl('/site path/DocumentLibrary/folder1')/Files is not the same as /_api/web/lists/getbytitle('DocumentLibrary')/items?$Select=FileDirRef,FileLeafRef&$filter=startswith(FileDirRef, '/sites/abc/DocumentLibrary/folder1') (if it would work).

Marking this as answer is MISLEADING.

  1. First one returns only files, while the second one could return files and folders. So if you need folders, you should use the second call like /_api/web/GetFolderByServerRelativeUrl('/site path/DocumentLibrary/folder1')/Folders or combine both calls in batch (which is recently possible in Office 365)
  2. First one returns SP.File, and second one returns SP.Item, which is different set of metadata.

I think that filtering by FileDearRef would be useful, as in other case, you have to make few more REST calls or a lot of calls, or eventually use JSOM and CAML queries ( :-( ).

I assume that Microsoft is not going to enable this as is busy with creating completely new API - Office 365 API.

April 9th, 2015 7:38pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics