5

I'm trying to access an SPS 2010 document library that contains folders, which in turn contain documents. I can successfully list the content of the library and see all folders and root-level documents, yet I can't figure out the way to list the contents of a library folder.

For example, a site has a library called Shared Documents, which in turn contains a folder called F1. I can successfully list the contents of the Shared Documents library:

https://contoso.com/_vti_bin/ListData.svc/SharedDocuments

and even retrieve details for the folder:

https://contoso.com/_vti_bin/ListData.svc/SharedDocuments(3)

but I can't figure out how to list the contents of the folder F1. For example, the most obvious thing doesn't work:

https://contoso.com/_vti_bin/ListData.svc/SharedDocuments/F1

This returns an error that I can't fathom:

The request URI is not valid. Since the segment 'SharedDocuments' refers to a collection, this must be the last segment in the request URI. All intermediate segments must refer to a single resource.

Neither does this:

https://contoso.com/SharedDocuments/_vti_bin/ListData.svc/F1

That request errors out without much specific information.

Sadly, I have to use the REST API, no other methods are acceptable in this specific case. Is it even possible to list subfolders with the REST API on 2010?

1 Answer 1

1

In order to return items from a specific folder use $filter query option with Path property:

$filter=Path eq '<folder relative url>'

Example

Assume a Documents library that contains Orders folder.

Then, the following REST query returns all documents located under Orders folder:

https://contoso.sharepoint.com/_vti_bin/ListData.svc/Documents?$filter=Path eq '/Shared Documents/Orders'

References

Use OData query operations in SharePoint REST requests

3
  • 1
    Thank you! I couldn't have figured that one out in another million years! Commented Jun 25, 2014 at 6:52
  • It's a good question indeed, glad this helped you! :) Commented Jun 25, 2014 at 6:57
  • If my SP URL is: localhost/org/uk/sms/shared documents/forms/allitems.aspx what would the Path variable be to get a REST XML list of documents in that folder?
    – Chris M
    Commented May 20, 2016 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.