Folder recursive search

Overview

This endpoint is one of Sitefinity’s OData web services custom methods. Custom methods are denoted by the Default.{MethodName} convention.

Custom methods are one of the following:

  • Bound
    Bound methods require an entity to execute.
    In this case, FoldersRecursiveSearch is a bound method.
  • Unbound
    Unbound methods do not require an entity to execute.

The FoldersRecursiveSearch method can be executed for the following entity sets:

  • albums
  • videolibraries
  • documentlibraries

To run a recursive folder search, execute a GET request to the following endpoint:

{baseUrl}/api/default/{entity}/Default.FoldersRecursiveSearch(parentId={itemId}

Where:

  • {entity} is the entity of the module that you are working with. It is one of albums, videolibraries, or documentlibraries.
  • {itemId} is the ID of the library where you want to execute the method. It can be null.

The method has an optional query string parameter ?recursive=true. If you omit it, it defaults to false.

  • If you use the method with ?recursive=true, it will return all levels of folders of the targeted library.
  • If you use the method with recursive=false, the endpoint will return only the first level.

This method returns a DTO with the following properties:

  • Breadcrumb: Array
  • ChildrenCount: Number
  • Description: String
  • FoldersCount: Number
  • Id: GUID
  • LastUploaded: Date
  • LastUploadedBy: Sting
  • MaxLibrarySizeInKb: Number
  • ParentId: GUID?
  • PreviewItems: Array
  • RootId: GUID?
  • RunningTask: GUID?
  • Storage: String
  • Title: String
  • TotalLibrarySizeInKb: Number

EXAMPLE: The following examples use the structure of Sitefinity CMS Document libray. There are two root libraries – Presentations and Samples. The Samples library has one child folder – Large documents. If the FoldersRecursiveSearch method is called recursively, without specifying a parent, it will return all of these items.

Execute recursive search

Sample request

GET http://mysite.com/api/default/documentlibraries/Default.FoldersRecursiveSearch(parentId=null)?recursive=true

Sample response

Execute non-recursive search

Alternatively, if the method is called without the ?recursive query parameter, it defaults to ?recursive=false. The result will not include the child folder Large documents.

Sample request

GET http://mysite.com/api/default/documentlibraries/Default.FoldersRecursiveSearch(parentId=null)

Sample response

Execute a search with partentID

When you call the FoldersRecursiveSearch method with a populated parentId parameter, the method returns the folders only of the targeted library. This example uses the ID of the Samples library from the previous example – 13f352fe-5bcc-4374-a234-0376f68bebc0.

Sample request

GET http://mysite.com/api/default/documentlibraries/Default.FoldersRecursiveSearch(parentId=13f352fe-5bcc-4374-a234-0376f68bebc0)

Sample response

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?