Kentico CMS 7.0 Developer's Guide

Data retrieval methods

Data retrieval methods

Previous topic Next topic Mail us feedback on this topic!  

Data retrieval methods

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

This page contains examples of REST URLs that can be requested to retrieve document or object data from a Kentico CMS instance using the REST service.

 

Note: The URLs are listed as relative, so if your instance is running at http://localhost/KenticoCMS, perform requests listed as ~/rest in format http://localhost/KenticoCMS/rest.

 

Document retrieval methods

 

Below, you can find examples of URLs under which object GET requests can be performed to retrieve document data from a Kentico CMS instance. You can also achieve a more detailed specification of retrieved data by appending querystring parameters to the URLs.

 

See URL parameters for more information.

 

Returns a single document of the given culture on the specified site:

~/rest/content/site/<sitename>/<culture>/document/<aliaspath>, e.g. ~/rest/content/site/corporatesite/en-us/document/company/careers

~/rest/content/currentsite/<culture>/document/<aliaspath>, e.g. ~/rest/content/currentsite/en-us/document/company/careers

 

Returns all documents which start with the specified alias path:

~/rest/content/site/<sitename>/<culture>/all/<aliaspath>, e.g. ~/rest/content/site/corporatesite/en-us/all/news

~/rest/content/currentsite/<culture>/all/<aliaspath>, e.g. ~/rest/content/currentsite/en-us/all/news

 

Returns all child documents of the given document:

~/rest/content/site/<sitename>/<culture>/childrenof/<aliaspath>, e.g. ~/rest/content/site/corporatesite/en-us/childrenof/news

~/rest/content/currentsite/<culture>/childrenof/<aliaspath>, e.g. ~/rest/content/currentsite/en-us/childrenof/news

 

 

InfoBox_Note

 

Constants for default culture and all cultures

 

If you want to get documents in the default culture, there is a special constant defaultculture, which you can use instead of the culture string. The same applies for all cultures, while the constant is allcultures in this case.

 

 

Object data retrieval methods

 

Below, you can find examples of URLs under which object GET requests can be performed to retrieve object data from a Kentico CMS instance. You can also achieve a more detailed specification of retrieved data by appending querystring parameters to the URLs.

 

See URL parameters for more information.

 

 

InfoBox_Note

 

Object ID, GUID and code name

 

In all of the examples below, object ID, object GUID and object code name are interchangeable, i.e. you can use any of them to specify the respective object.

 

When using code names of site-related objects, the object with the code name assigned to the current site is always returned, unless a site is explicitly specified in the URL.

 

 

Exposes the service document (for ODATA browisng). The document contains a list of all available object types and URLs under which objects of the type can be accessed:

~/rest

 

Returns all objects of the given object type (both site objects from all sites and global objects):

~/rest/<objecttype>/all, e.g. ~/rest/cms.emailtemplate/all

 

 

InfoBox_Exclamation

 

Note

 

The REST service does not allow /all object retrieval for requests that use the hash URL parameter for authentication. This is an intentional security limitation that protects global data.

 

 

Returns all objects of the given object type assigned to the current site. If there is no site binding for the given object type, it returns all objects of the given type:

~/rest/<objecttype>, e.g. ~/rest/cms.country

~/rest/<objecttype>/currentsite, e.g. ~/rest/cms.country/currentsite

 

Returns all objects of the given object type assigned to the specified site. If there is no site binding for the given object type, it returns all objects of the given type:

~/rest/<objecttype>/site/<sitecodename>, e.g. ~/rest/cms.country/site/corporatesite
 

Returns all global objects of the given object type (which are not assigned to any site). If there is no site binding for the given object type, it returns all objects of the given type:

~/rest/<objecttype>/global, e.g. ~/rest/cms.emailtemplate/global

 

Returns all sites on which the specified object type is available to the currently authenticated user and URLs under which the objects for the particular sites can be retrieved (for ODATA browsing):

~/rest/<objecttype>/site, e.g. ~/rest/cms.country/site

 

Returns an object of the given type with the specified ID, GUID or code name:

~/rest/<objecttype>/<id>, e.g. ~/rest/cms.country/271

 

Returns an object of the given type with the specified code name assigned to the current site:

~/rest/<objecttype>/<objectcodename>, e.g. ~/rest/cms.country/usa

~/rest/<objecttype>/currentsite/<objectcodename>, e.g. ~/rest/cms.country/currentsite/usa
 

Returns a global object of the given type with the specified name:

~/rest/<objecttype>/global/<objectcodename>, e.g. ~/rest/cms.emailtemplate/global/Blog.NotificationToModerators

 

Returns all supported child object types for the given object (only object ID can be used in this URL, not code name or GUID):

~/rest/<objecttype>/<id>/children, e.g. ~/rest/cms.country/271/children
 

Returns all child objects of the specified object and of the given object type (only object ID can be used in this URL, not code name or GUID):

~/rest/<objecttype>/<id>/children/<childrenobjecttype>, e.g. ~/rest/cms.country/271/children/cms.state
 

Returns all binding object types supported by the given object (only object ID can be used in this URL, not code name or GUID):

~/rest/<objecttype>/<id>/bindings, e.g. ~/rest/cms.user/53/bindings
 

Returns all binding objects of the given type of the specified object (only object ID can be used in this URL, not code name or GUID):

~/rest/<objecttype>/<id>/bindings/<bindingobjecttype>, e.g. ~/rest/cms.user/53/bindings/cms.usersite
 

Returns TypeInfo of the given object type:

~/rest/typeinfo/<objecttype>, e.g. ~/rest/typeinfo/cms.user
 

Evaluates the given macro expression (without the encapsulating character sequence and with forbidden characters URL-encoded) and serializes the result:

~/rest/macro/<expression>, e.g. ~/rest/macro/CurrentSite.SiteName

 

Custom table and Form data items vs. class definition

 

When working with custom tables or forms via the REST service, you need to use different URLs when you want to specify the table's or form's class definition and when you want to specify the data items stored in the custom table or form.

 

For class definition, you need to use:

 

~/rest/cms.customtable/<customtablecodename>, e.g. ~/rest/cms.customtable/customtable.sampletable

~/rest/cms.form/<formcodename>, e.g. ~/rest/cms.form/contactus

 

For the actual data items, you need to use:

 

~/rest/customtableitem.<customtablecodename>, e.g. ~/rest/customtableitem.customtable.sampletable

~/rest/bizformitem.bizform.<formcodename>, e.g. ~/rest/bizformitem.bizform.contactus

 

GET request result encoding

 

Data retrieval (GET) requests return the results encoded using the default server encoding. If you want to get the result in a different encoding, you need to specify the required encoding in the Accept-Charset field of the HTTP GET request. If the specified encoding is not available, the default encoding specified in REST settings is used.

 

For example:

 

GET http://localhost/CMS/rest/cms.user/administrator HTTP/1.1

User-Agent: Fiddler

Authorization: Basic <enter Base64-encoded <username>:<password> here>

Accept-Charset: utf-8

Host: localhost

Content-Type: text\xml