Sitefinity CMS enables developers to work with the out of the box OData services, providing full support for the OData syntax. Refer to this article for a list of common OData queries with Sitefinity CMS content. For additional information and more examples on OData queries syntax, refer to the OData official documentation.
Supported syntax exceptions
Sitefinity CMS supports all the OData syntax, with some exceptions applying to the Sitefinity CMS dynamic model, which does not allow querying in the same manner as the OData protocol allows. These exceptions exist due to the lack of direct relations in the class structures, which the OData LINQ translator relies on.
To allow for seamless configuration of data relations in both static and dynamic modules, the Sitefinity CMS RelatedData implementation is based on ContentLiks. The ContentLiks architecture manages data relations externally from the data classes you relate. For example, if you have a content type Order, and a related data type OrderDetails, in the standard scenario OData would expect that the class OrderDetails has a property storing the Order ID, and the OData query: orderDetails$filter=Order/Id eq ‘some id’ would result in the following LINQ query: context.OrderDetails.Where(x => x.Id == ‘some id’). In the Sitefinity CMS architecture, the relationship between Order and OrderDetail is handled on ContentLinks level, thus there is no Order property on OrderDetail dynamic class. That’s why Sitefinity CMS does not support complex OData operations with RelatedData, and you need to use Sitefinity CMS specific syntax when working with such fields.
Sitefinity CMS persists ChoiceField choices in a specific pattern. When using ChoiceField in an OData service filter, the CLR type to which a choice field value is resolved is Enum. You need to cast it to Edm.String to be able to filter collections by ChoiceField choices. For example, http://localhost/api/<entity>/<type>?$filter=cast(<ChoiceFieldName>, 'Edm.String') eq 'MyChoiceValue '
Using the sample queries
All sample queries listed in this section target the /api/default route. If you have created a custom web service or changed the route URL you must adjust the web service call to match the proper route. For more information see:Web service routes.
Authenticate the request
By default, the Sitefinity CMS OData web services are secured. You need to obtain an authentication token and pass it as an Authorization header, so you can work with the services. For more information see: Request access token for calling web services.
Get a token
Request type: POST