You create items using the CreateItem of the IRestClient interface.
CreateItem
IRestClient
The following example create a news item with title Sample title:
Sample
You can set a custom field for built-in types using the SetValue method. The following code creates a news item with title Sample title and sets the value of its MyCustomFieldName field to My custom field value:
SetValue
Sample title
MyCustomFieldName
My custom field value
The following code creates a press release item with title Sample title and sets the value of its MyCustomFieldName field to My custom field value:
NOTE: You can optionally provide a provider name, which will create the item in a specified provider.
You retrieve items using the GetItem of the IRestClient interface.
GetItem
You can retrieve a single item, using one of the following methods:
NOTE: These methods retrieve all of the fields of the item - both plain and related.
The IRestClient interface has a method that allows more granular control over the retrieved item’s fields:
The GetItemArgs argument holds properties that enable more granular control over the fetching of an item like in the following example:
GetItemArgs
NOTE: the Type property is not required, if the generic argument (in this case <NewsDto>) is decorated with the MapppedSitefinityContentTypeAttribute.
<NewsDto>
MapppedSitefinityContentTypeAttribute
EXAMPLE: The following example retrieves a single news item by passing an id only: restClient.GetItem(Guid.NewGuid().ToString());
restClient.GetItem(Guid.NewGuid().ToString());
You update items using the UpdateItem of the IRestClient interface.
UpdateItem
The following code updates the title of the news item with the specified ID to Sample title:
You can set a custom field for built-in types using the SetValue method. The following code updates the title of the news item with the specified ID to Sample title and the value of its MyCustomFieldName field to My custom field value:
SetValue method
The following code updates the title of the press release with the specified ID to Sample title and the value of its MyCustomFieldName field to My custom field value:
You delete items using the DeleteItem of the IRestClient interface.
DeleteItem
The following code deletes the news item with the specified ID:
The following code deletes the press release with the specified ID:
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important