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
cultureDictionaryICultureDictionaryloggerFactoryILoggerFactoryshortStringHelperIShortStringHelpereventMessagesIEventMessagesFactorylocalizedTextServiceILocalizedTextServicepropertyEditorsPropertyEditorCollectioncontentServiceIContentServiceuserServiceIUserServicebackofficeSecurityAccessorIBackOfficeSecurityAccessorcontentTypeServiceIContentTypeServiceumbracoMapperIUmbracoMapperpublishedUrlProviderIPublishedUrlProviderdomainServiceIDomainServicedataTypeServiceIDataTypeServicelocalizationServiceILocalizationServicefileServiceIFileServicenotificationServiceINotificationServiceactionCollectionActionCollectionsqlContextISqlContextserializerIJsonSerializerscopeProviderICoreScopeProviderauthorizationServiceIAuthorizationServicecontentVersionServiceIContentVersionService
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
cultureDictionaryICultureDictionaryloggerFactoryILoggerFactoryshortStringHelperIShortStringHelpereventMessagesIEventMessagesFactorylocalizedTextServiceILocalizedTextServicepropertyEditorsPropertyEditorCollectioncontentServiceIContentServiceuserServiceIUserServicebackofficeSecurityAccessorIBackOfficeSecurityAccessorcontentTypeServiceIContentTypeServiceumbracoMapperIUmbracoMapperpublishedUrlProviderIPublishedUrlProviderdomainServiceIDomainServicedataTypeServiceIDataTypeServicelocalizationServiceILocalizationServicefileServiceIFileServicenotificationServiceINotificationServiceactionCollectionActionCollectionsqlContextISqlContextserializerIJsonSerializerscopeProviderICoreScopeProviderauthorizationServiceIAuthorizationServicecontentVersionServiceIContentVersionServicecultureImpactFactoryICultureImpactFactory
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
cultureDictionaryICultureDictionaryloggerFactoryILoggerFactoryshortStringHelperIShortStringHelpereventMessagesIEventMessagesFactorylocalizedTextServiceILocalizedTextServicepropertyEditorsPropertyEditorCollectioncontentServiceIContentServiceuserServiceIUserServicebackofficeSecurityAccessorIBackOfficeSecurityAccessorcontentTypeServiceIContentTypeServiceumbracoMapperIUmbracoMapperpublishedUrlProviderIPublishedUrlProviderdomainServiceIDomainServicedataTypeServiceIDataTypeServicelocalizationServiceILocalizationServicefileServiceIFileServicenotificationServiceINotificationServiceactionCollectionActionCollectionsqlContextISqlContextserializerIJsonSerializerscopeProviderICoreScopeProviderauthorizationServiceIAuthorizationServicecontentVersionServiceIContentVersionServicecultureImpactFactoryICultureImpactFactorycontentSettingsIOptions<ContentSettings>
Properties
Domains
public object? Domains { get; }
Property Value
Methods
CreateBlueprintFromContent(int, string)
Creates a blueprint from a content item
[Authorize(Policy = "ContentPermissionCreateBlueprintFromId")]
[HttpPost]
public ActionResult<SimpleNotificationModel> CreateBlueprintFromContent(int contentId, string name)
Parameters
Returns
- ActionResult<SimpleNotificationModel>
DeleteBlueprint(int)
[Authorize(Policy = "TreeAccessDocumentTypes")]
[HttpDelete]
[HttpPost]
public IActionResult DeleteBlueprint(int id)
Parameters
idint
Returns
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
idint
Returns
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
Remarks
attributed with EnsureUserPermissionForContent to verify the user has access to the recycle bin
GetBlueprintById(int)
public ActionResult<ContentItemDisplay?> GetBlueprintById(int id)
Parameters
idint
Returns
- ActionResult<ContentItemDisplay>
GetById(Guid)
Gets the content json for the content guid
[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<ContentItemDisplayWithSchedule?> GetById(Guid id)
Parameters
idGuid
Returns
- ActionResult<ContentItemDisplayWithSchedule>
GetById(int)
Gets the content json for the content id
[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<ContentItemDisplayWithSchedule?> GetById(int id)
Parameters
idint
Returns
- ActionResult<ContentItemDisplayWithSchedule>
GetById(Udi)
Gets the content json for the content udi
[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<ContentItemDisplayWithSchedule?> GetById(Udi id)
Parameters
idUdi
Returns
- ActionResult<ContentItemDisplayWithSchedule>
GetByIds(int[])
Return content for the specified ids
public IEnumerable<ContentItemDisplay> GetByIds(int[] ids)
Parameters
idsint[]
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
idintincludePropertiesstringpageNumberintpageSizeintorderBystringorderDirectionDirectionorderBySystemFieldboolfilterstringcultureNamestring
Returns
- PagedResult<ContentItemBasic<ContentPropertyBasic>>
GetCultureAndDomains(int)
public ContentDomainsAndCulture GetCultureAndDomains(int id)
Parameters
idint
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
contentIdint
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
Returns
- ActionResult<ContentItemDisplay>
GetEmptyBlueprint(int, int)
public ActionResult<ContentItemDisplay?> GetEmptyBlueprint(int blueprintId, int parentId)
Parameters
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
contentTypesByAliasesContentTypesByAliases
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
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
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
contentTypeByKeysContentTypesByKeys
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
idGuid
Returns
GetNiceUrl(int)
Gets the Url for a given node ID
public IActionResult GetNiceUrl(int id)
Parameters
idint
Returns
GetNiceUrl(Udi)
Gets the Url for a given node ID
public IActionResult GetNiceUrl(Udi id)
Parameters
idUdi
Returns
GetNotificationOptions(int)
[Authorize(Policy = "ContentPermissionBrowseById")]
public ActionResult<IEnumerable<NotifySetting>> GetNotificationOptions(int contentId)
Parameters
contentIdint
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
Returns
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
Returns
- ContentVariantDisplay
GetRollbackVersions(int, string?)
[HttpGet]
public IEnumerable<RollbackVersion> GetRollbackVersions(int contentId, string? culture = null)
Parameters
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
copyMoveOrCopy
Returns
- Task<ActionResult<IContent>>
PostMove(MoveOrCopy)
Change the sort order for media
public Task<IActionResult?> PostMove(MoveOrCopy move)
Parameters
moveMoveOrCopy
Returns
PostNotificationOptions(int, string[])
public IActionResult PostNotificationOptions(int contentId, string[] notifyOptions)
Parameters
Returns
PostPublishById(int)
Publishes a document with a given ID
[Authorize(Policy = "ContentPermissionPublishById")]
public IActionResult PostPublishById(int id)
Parameters
idint
Returns
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
modelPublishContent
Returns
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
Returns
PostSave(ContentItemSave)
Saves content
[FileUploadCleanupFilter(true)]
[ContentSaveValidation(false)]
public Task<ActionResult<ContentItemDisplay<ContentVariantScheduleDisplay>?>> PostSave(ContentItemSave contentItem)
Parameters
contentItemContentItemSave
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
contentItemContentItemSave
Returns
- Task<ActionResult<ContentItemDisplay<ContentVariantDisplay>>>
PostSaveLanguageAndDomains(DomainSave)
[HttpPost]
public ActionResult<DomainSave> PostSaveLanguageAndDomains(DomainSave model)
Parameters
modelDomainSave
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
saveModelUserGroupPermissionsSave
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
Returns
PostSort(ContentSortOrder)
Change the sort order for content
public Task<IActionResult> PostSort(ContentSortOrder sorted)
Parameters
sortedContentSortOrder
Returns
PostUnpublish(UnpublishContent)
Unpublishes a node with a given Id and returns the unpublished entity
public Task<ActionResult<ContentItemDisplayWithSchedule?>> PostUnpublish(UnpublishContent model)
Parameters
modelUnpublishContentThe content and variants to unpublish
Returns
- Task<ActionResult<ContentItemDisplayWithSchedule>>