I'm using REST to query SharePoint 2013. I need to return a complete list of all files contained in a document library including subfolders. This query itself works correctly using a POST request:
<site collection url>/_api/web/Lists/GetByTitle('MyDocLib')/GetItems?$expand=Folder,File,File/ModifiedBy
with the following CAML query as the payload:
{"query":{ "__metadata": { "type": "SP.CamlQuery" }, "ViewXml": "<View Scope=\"RecursiveAll\"><Query><Where><Eq><FieldRef Name=\"FSObjType\" /><Value Type=\"Integer\">0<\/Value><\/Eq><\/Where><\/Query><\/View>" }}
My issue is that SharePoint is ignoring the expand query option for Folder. It properly expands File and File/ModifiedBy.
I'm at a loss here. I need to retrieve the folder information associated with each file so I can present the relative folder to the end user.
I considered doing a second query to retrieve the folder information for each file, but a query to the deferred folder URI returns null data.
So, am I building the query incorrectly? or is the expand query option for Folder broken?
New Information:
I've narrowed the issue to the Items collection. The following query works:
<SP site collection url>/_api/Web/Lists('855b5c5f-2ecc-4747-a78f-b0b8772f64b9')/Items?$expand=folder
It returns a result set of all the items in the collection with the folder attribute properly expanded.
This does not work:
<sp site collection url>_api/Web/Lists('855b5c5f-2ecc-4747-a78f-b0b8772f64b9')/Items(1)?$expand=folder
nor does this:
<sp site collection url>_api/Web/Lists('855b5c5f-2ecc-4747-a78f-b0b8772f64b9')/Items(1)/Folder
The first returns a result set with the indexed item, but the folder attribute is not expanded. The second returns a null set. It seems as though working on indexed items in the item collection is not supported. Is this a bug or intended?