Table of Contents

Class ContentController

Namespace
Umbraco.Cms.Web.BackOffice.Controllers
Assembly
Umbraco.Web.BackOffice.dll

The API controller used for editing content

[Authorize(Policy = "TreeAccessDocuments")]
public class ContentController : ContentControllerBase
Inheritance
ContentController
Inherited Members

Constructors

ContentController(ICultureDictionary, ILoggerFactory, IShortStringHelper, IEventMessagesFactory, ILocalizedTextService, PropertyEditorCollection, IContentService, IUserService, IBackOfficeSecurityAccessor, IContentTypeService, IUmbracoMapper, IPublishedUrlProvider, IDomainService, IDataTypeService, ILocalizationService, IFileService, INotificationService, ActionCollection, ISqlContext, IJsonSerializer, ICoreScopeProvider, IAuthorizationService, IContentVersionService)

[Obsolete("Use constructor that accepts ICultureImpactService as a parameter, scheduled for removal in V12")]
public ContentController(ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IContentService contentService, IUserService userService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IContentTypeService contentTypeService, IUmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider, IDomainService domainService, IDataTypeService dataTypeService, ILocalizationService localizationService, IFileService fileService, INotificationService notificationService, ActionCollection actionCollection, ISqlContext sqlContext, IJsonSerializer serializer, ICoreScopeProvider scopeProvider, IAuthorizationService authorizationService, IContentVersionService contentVersionService)

Parameters

cultureDictionary ICultureDictionary
loggerFactory ILoggerFactory
shortStringHelper IShortStringHelper
eventMessages IEventMessagesFactory
localizedTextService ILocalizedTextService
propertyEditors PropertyEditorCollection
contentService IContentService
userService IUserService
backofficeSecurityAccessor IBackOfficeSecurityAccessor
contentTypeService IContentTypeService
umbracoMapper IUmbracoMapper
publishedUrlProvider IPublishedUrlProvider
domainService IDomainService
dataTypeService IDataTypeService
localizationService ILocalizationService
fileService IFileService
notificationService INotificationService
actionCollection ActionCollection
sqlContext ISqlContext
serializer IJsonSerializer
scopeProvider ICoreScopeProvider
authorizationService IAuthorizationService
contentVersionService IContentVersionService

ContentController(ICultureDictionary, ILoggerFactory, IShortStringHelper, IEventMessagesFactory, ILocalizedTextService, PropertyEditorCollection, IContentService, IUserService, IBackOfficeSecurityAccessor, IContentTypeService, IUmbracoMapper, IPublishedUrlProvider, IDomainService, IDataTypeService, ILocalizationService, IFileService, INotificationService, ActionCollection, ISqlContext, IJsonSerializer, ICoreScopeProvider, IAuthorizationService, IContentVersionService, ICultureImpactFactory)

[Obsolete("Use constructor that accepts ContentSettings as a parameter, scheduled for removal in V13")]
public ContentController(ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IContentService contentService, IUserService userService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IContentTypeService contentTypeService, IUmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider, IDomainService domainService, IDataTypeService dataTypeService, ILocalizationService localizationService, IFileService fileService, INotificationService notificationService, ActionCollection actionCollection, ISqlContext sqlContext, IJsonSerializer serializer, ICoreScopeProvider scopeProvider, IAuthorizationService authorizationService, IContentVersionService contentVersionService, ICultureImpactFactory cultureImpactFactory)

Parameters

cultureDictionary ICultureDictionary
loggerFactory ILoggerFactory
shortStringHelper IShortStringHelper
eventMessages IEventMessagesFactory
localizedTextService ILocalizedTextService
propertyEditors PropertyEditorCollection
contentService IContentService
userService IUserService
backofficeSecurityAccessor IBackOfficeSecurityAccessor
contentTypeService IContentTypeService
umbracoMapper IUmbracoMapper
publishedUrlProvider IPublishedUrlProvider
domainService IDomainService
dataTypeService IDataTypeService
localizationService ILocalizationService
fileService IFileService
notificationService INotificationService
actionCollection ActionCollection
sqlContext ISqlContext
serializer IJsonSerializer
scopeProvider ICoreScopeProvider
authorizationService IAuthorizationService
contentVersionService IContentVersionService
cultureImpactFactory ICultureImpactFactory

ContentController(ICultureDictionary, ILoggerFactory, IShortStringHelper, IEventMessagesFactory, ILocalizedTextService, PropertyEditorCollection, IContentService, IUserService, IBackOfficeSecurityAccessor, IContentTypeService, IUmbracoMapper, IPublishedUrlProvider, IDomainService, IDataTypeService, ILocalizationService, IFileService, INotificationService, ActionCollection, ISqlContext, IJsonSerializer, ICoreScopeProvider, IAuthorizationService, IContentVersionService, ICultureImpactFactory, IOptions<ContentSettings>)

[ActivatorUtilitiesConstructor]
public ContentController(ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IContentService contentService, IUserService userService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IContentTypeService contentTypeService, IUmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider, IDomainService domainService, IDataTypeService dataTypeService, ILocalizationService localizationService, IFileService fileService, INotificationService notificationService, ActionCollection actionCollection, ISqlContext sqlContext, IJsonSerializer serializer, ICoreScopeProvider scopeProvider, IAuthorizationService authorizationService, IContentVersionService contentVersionService, ICultureImpactFactory cultureImpactFactory, IOptions<ContentSettings> contentSettings)

Parameters

cultureDictionary ICultureDictionary
loggerFactory ILoggerFactory
shortStringHelper IShortStringHelper
eventMessages IEventMessagesFactory
localizedTextService ILocalizedTextService
propertyEditors PropertyEditorCollection
contentService IContentService
userService IUserService
backofficeSecurityAccessor IBackOfficeSecurityAccessor
contentTypeService IContentTypeService
umbracoMapper IUmbracoMapper
publishedUrlProvider IPublishedUrlProvider
domainService IDomainService
dataTypeService IDataTypeService
localizationService ILocalizationService
fileService IFileService
notificationService INotificationService
actionCollection ActionCollection
sqlContext ISqlContext
serializer IJsonSerializer
scopeProvider ICoreScopeProvider
authorizationService IAuthorizationService
contentVersionService IContentVersionService
cultureImpactFactory ICultureImpactFactory
contentSettings IOptions<ContentSettings>

Properties

Domains

public object? Domains { get; }

Property Value

object

Methods

CreateBlueprintFromContent(int, string)

Creates a blueprint from a content item

[Authorize(Policy = "ContentPermissionCreateBlueprintFromId")]
[HttpPost]
public ActionResult<SimpleNotificationModel> CreateBlueprintFromContent(int contentId, string name)

Parameters

contentId int

The content id to copy

name string

The name of the blueprint

Returns

ActionResult<SimpleNotificationModel>

DeleteBlueprint(int)

[Authorize(Policy = "TreeAccessDocumentTypes")]
[HttpDelete]
[HttpPost]
public IActionResult DeleteBlueprint(int id)

Parameters

id int

Returns

IActionResult

DeleteById(int)

Moves an item to the recycle bin, if it is already there then it will permanently delete it

[Authorize(Policy = "ContentPermissionDeleteById")]
[HttpDelete]
[HttpPost]
public IActionResult DeleteById(int id)

Parameters

id int

Returns

IActionResult

Remarks

The CanAccessContentAuthorize attribute will deny access to this method if the current user does not have Delete access to this node.

EmptyRecycleBin()

Empties the recycle bin

[HttpDelete]
[HttpPost]
[Authorize(Policy = "ContentPermissionEmptyRecycleBin")]
public IActionResult EmptyRecycleBin()

Returns

IActionResult

Remarks

attributed with EnsureUserPermissionForContent to verify the user has access to the recycle bin

GetBlueprintById(int)

public ActionResult<ContentItemDisplay?> GetBlueprintById(int id)

Parameters

id int

Returns

ActionResult<ContentItemDisplay>

GetById(Guid)

Gets the content json for the content guid

[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<ContentItemDisplayWithSchedule?> GetById(Guid id)

Parameters

id Guid

Returns

ActionResult<ContentItemDisplayWithSchedule>

GetById(int)

Gets the content json for the content id

[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<ContentItemDisplayWithSchedule?> GetById(int id)

Parameters

id int

Returns

ActionResult<ContentItemDisplayWithSchedule>

GetById(Udi)

Gets the content json for the content udi

[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<ContentItemDisplayWithSchedule?> GetById(Udi id)

Parameters

id Udi

Returns

ActionResult<ContentItemDisplayWithSchedule>

GetByIds(int[])

Return content for the specified ids

public IEnumerable<ContentItemDisplay> GetByIds(int[] ids)

Parameters

ids int[]

Returns

IEnumerable<ContentItemDisplay>

GetChildren(int, string, int, int, string, Direction, bool, string, string)

Gets the children for the content id passed in

public PagedResult<ContentItemBasic<ContentPropertyBasic>> GetChildren(int id, string includeProperties, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = 0, bool orderBySystemField = true, string filter = "", string cultureName = "")

Parameters

id int
includeProperties string
pageNumber int
pageSize int
orderBy string
orderDirection Direction
orderBySystemField bool
filter string
cultureName string

Returns

PagedResult<ContentItemBasic<ContentPropertyBasic>>

GetCultureAndDomains(int)

public ContentDomainsAndCulture GetCultureAndDomains(int id)

Parameters

id int

Returns

ContentDomainsAndCulture

GetDetailedPermissions(int)

Returns the user group permissions for user groups assigned to this node

[Authorize(Policy = "ContentPermissionAdministrationById")]
public ActionResult<IEnumerable<AssignedUserGroupPermissions?>?> GetDetailedPermissions(int contentId)

Parameters

contentId int

Returns

ActionResult<IEnumerable<AssignedUserGroupPermissions>>

Remarks

Permission check is done for letter 'R' which is for Umbraco.Cms.Core.Actions.ActionRights which the user must have access to view

GetEmpty(string, int)

Gets an empty content item for the document type.

public ActionResult<ContentItemDisplay?> GetEmpty(string contentTypeAlias, int parentId)

Parameters

contentTypeAlias string
parentId int

Returns

ActionResult<ContentItemDisplay>

GetEmptyBlueprint(int, int)

public ActionResult<ContentItemDisplay?> GetEmptyBlueprint(int blueprintId, int parentId)

Parameters

blueprintId int
parentId int

Returns

ActionResult<ContentItemDisplay>

GetEmptyByAliases(ContentTypesByAliases)

Gets a dictionary containing empty content items for every alias specified in the contentTypeAliases array in the body of the request.

[HttpPost]
public ActionResult<IDictionary<string, ContentItemDisplay>> GetEmptyByAliases(ContentTypesByAliases contentTypesByAliases)

Parameters

contentTypesByAliases ContentTypesByAliases

Returns

ActionResult<IDictionary<string, ContentItemDisplay>>

Remarks

This is a post request in order to support a large amount of aliases without hitting the URL length limit.

GetEmptyByKey(Guid, int)

Gets an empty content item for the document type.

public ActionResult<ContentItemDisplay?> GetEmptyByKey(Guid contentTypeKey, int parentId)

Parameters

contentTypeKey Guid
parentId int

Returns

ActionResult<ContentItemDisplay>

GetEmptyByKeys(Guid[], int)

Gets a collection of empty content items for all document types.

public ActionResult<IDictionary<Guid, ContentItemDisplay>> GetEmptyByKeys(Guid[] contentTypeKeys, int parentId)

Parameters

contentTypeKeys Guid[]
parentId int

Returns

ActionResult<IDictionary<Guid, ContentItemDisplay>>

GetEmptyByKeys(ContentTypesByKeys)

Gets a collection of empty content items for all document types.

[HttpPost]
public ActionResult<IDictionary<Guid, ContentItemDisplay>> GetEmptyByKeys(ContentTypesByKeys contentTypeByKeys)

Parameters

contentTypeByKeys ContentTypesByKeys

Returns

ActionResult<IDictionary<Guid, ContentItemDisplay>>

Remarks

This is a post request in order to support a large amount of GUIDs without hitting the URL length limit.

GetNiceUrl(Guid)

Gets the Url for a given node ID

public IActionResult GetNiceUrl(Guid id)

Parameters

id Guid

Returns

IActionResult

GetNiceUrl(int)

Gets the Url for a given node ID

public IActionResult GetNiceUrl(int id)

Parameters

id int

Returns

IActionResult

GetNiceUrl(Udi)

Gets the Url for a given node ID

public IActionResult GetNiceUrl(Udi id)

Parameters

id Udi

Returns

IActionResult

GetNotificationOptions(int)

[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<IEnumerable<NotifySetting>> GetNotificationOptions(int contentId)

Parameters

contentId int

Returns

ActionResult<IEnumerable<NotifySetting>>

GetPagedContentVersions(int, int, int, string?)

[HttpGet]
[JsonCamelCaseFormatter]
public IActionResult GetPagedContentVersions(int contentId, int pageNumber = 1, int pageSize = 10, string? culture = null)

Parameters

contentId int
pageNumber int
pageSize int
culture string

Returns

IActionResult

GetRecycleBin()

Returns an item to be used to display the recycle bin for content

public ActionResult<ContentItemDisplay> GetRecycleBin()

Returns

ActionResult<ContentItemDisplay>

GetRollbackVersion(int, string?)

[HttpGet]
public ContentVariantDisplay? GetRollbackVersion(int versionId, string? culture = null)

Parameters

versionId int
culture string

Returns

ContentVariantDisplay

GetRollbackVersions(int, string?)

[HttpGet]
public IEnumerable<RollbackVersion> GetRollbackVersions(int contentId, string? culture = null)

Parameters

contentId int
culture string

Returns

IEnumerable<RollbackVersion>

PostCopy(MoveOrCopy)

Copies a content item and places the copy as a child of a given parent Id

public Task<ActionResult<IContent>?> PostCopy(MoveOrCopy copy)

Parameters

copy MoveOrCopy

Returns

Task<ActionResult<IContent>>

PostMove(MoveOrCopy)

Change the sort order for media

public Task<IActionResult?> PostMove(MoveOrCopy move)

Parameters

move MoveOrCopy

Returns

Task<IActionResult>

PostNotificationOptions(int, string[])

public IActionResult PostNotificationOptions(int contentId, string[] notifyOptions)

Parameters

contentId int
notifyOptions string[]

Returns

IActionResult

PostPublishById(int)

Publishes a document with a given ID

[Authorize(Policy = "ContentPermissionPublishById")]
public IActionResult PostPublishById(int id)

Parameters

id int

Returns

IActionResult

Remarks

The EnsureUserPermissionForContent attribute will deny access to this method if the current user does not have Publish access to this node.

PostPublishByIdAndCulture(PublishContent)

Publishes a document with a given ID and cultures.

[Authorize(Policy = "ContentPermissionPublishById")]
public IActionResult PostPublishByIdAndCulture(PublishContent model)

Parameters

model PublishContent

Returns

IActionResult

Remarks

The EnsureUserPermissionForContent attribute will deny access to this method if the current user does not have Publish access to this node.

PostRollbackContent(int, int, string?)

[Authorize(Policy = "ContentPermissionRollbackById")]
[HttpPost]
public IActionResult PostRollbackContent(int contentId, int versionId, string? culture = null)

Parameters

contentId int
versionId int
culture string

Returns

IActionResult

PostSave(ContentItemSave)

Saves content

[FileUploadCleanupFilter(true)]
[ContentSaveValidation(false)]
public Task<ActionResult<ContentItemDisplay<ContentVariantScheduleDisplay>?>> PostSave(ContentItemSave contentItem)

Parameters

contentItem ContentItemSave

Returns

Task<ActionResult<ContentItemDisplay<ContentVariantScheduleDisplay>>>

PostSaveBlueprint(ContentItemSave)

Saves content

[Authorize(Policy = "TreeAccessDocumentTypes")]
[FileUploadCleanupFilter(true)]
[ContentSaveValidation(true)]
public Task<ActionResult<ContentItemDisplay<ContentVariantDisplay>?>?> PostSaveBlueprint(ContentItemSave contentItem)

Parameters

contentItem ContentItemSave

Returns

Task<ActionResult<ContentItemDisplay<ContentVariantDisplay>>>

PostSaveLanguageAndDomains(DomainSave)

[HttpPost]
public ActionResult<DomainSave> PostSaveLanguageAndDomains(DomainSave model)

Parameters

model DomainSave

Returns

ActionResult<DomainSave>

PostSaveUserGroupPermissions(UserGroupPermissionsSave)

Updates the permissions for a content item for a particular user group

public Task<ActionResult<IEnumerable<AssignedUserGroupPermissions?>?>> PostSaveUserGroupPermissions(UserGroupPermissionsSave saveModel)

Parameters

saveModel UserGroupPermissionsSave

Returns

Task<ActionResult<IEnumerable<AssignedUserGroupPermissions>>>

Remarks

Permission check is done for letter 'R' which is for Umbraco.Cms.Core.Actions.ActionRights which the user must have access to update

PostSetContentVersionPreventCleanup(int, int, bool)

[HttpPost]
[Authorize(Policy = "ContentPermissionAdministrationById")]
public IActionResult PostSetContentVersionPreventCleanup(int contentId, int versionId, bool preventCleanup)

Parameters

contentId int
versionId int
preventCleanup bool

Returns

IActionResult

PostSort(ContentSortOrder)

Change the sort order for content

public Task<IActionResult> PostSort(ContentSortOrder sorted)

Parameters

sorted ContentSortOrder

Returns

Task<IActionResult>

PostUnpublish(UnpublishContent)

Unpublishes a node with a given Id and returns the unpublished entity

public Task<ActionResult<ContentItemDisplayWithSchedule?>> PostUnpublish(UnpublishContent model)

Parameters

model UnpublishContent

The content and variants to unpublish

Returns

Task<ActionResult<ContentItemDisplayWithSchedule>>