Query by Id or Path

Let's see what do you need to query a document by its Id or Path.

Query a content by its Id

Following example shows how to query the document with the Id 1607.

Copy
https://dev.demo.sensenet.com/OData.svc/Root/Content/IT?query=Id%3A1607

// the special characters should be url encoded
// the actual query here is ?query=Id:1607

Query multiple content by their Ids

The next example shows how to query multiple documents by Id's 1607, 1640 and 1645.

Copy
https://dev.demo.sensenet.com/OData.svc/Root/Content/IT?query=Id%3A%281607%201640%201645%29

// the special characters should be url encoded
// the actual query here is ?query=Id:(1607 1640 1645)

Search in a folder

You can specify a folder to search in using the InFolder param and the chosen parent's Path as its value in the query.

Following query returns the children of the folder named Calgary:

Copy
https://dev.demo.sensenet.com/OData.svc/Root?query=InFolder%3A%22/Root/Content/IT/Document_Library/Calgary%22

// the special characters should be url encoded
// the actual query here is ?query=InFolder:"/Root/Content/IT/Document_Library/Calgary"

Search in a branch of the content tree

You can also specify a branch of the content repository to search in using the InTree param and the Path of the root content of the chosen branch.

Following query returns all the content items which are stored in the IT workspace's document library even if they are stored in lower level folders:

Copy
https://dev.demo.sensenet.com/OData.svc/Root?query=InTree%3A%22/Root/Content/IT/Document_Library%22

// the special characters should be url encoded
// the actual query here is ?query=InTree:"/Root/Content/IT/Document_Library"