I'm trying to create content programmatically. I had already done this in previous versions (9 & 10), now I use Umbraco 12.2.0. Now when I call ContentService.CreateAndSave() I get an error that the content cannot be saved with an empty name. However, I pass the following string “roland-schenk” to the method. Are there any new restrictions on the names of a node?
System.InvalidOperationException: Cannot save content with an empty name.
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.EnsureInvariantNameExists(IContent content)
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.SanitizeNames(IContent content, Boolean publishing)
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.PersistNewItem(IContent entity)
at Umbraco.Cms.Core.Cache.DefaultRepositoryCachePolicy2.Create(TEntity entity, Action1 persistNew)
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase2.Save(TEntity entity)
at Umbraco.Cms.Core.Services.ContentService.Save(IContent content, Nullable1 userId, ContentScheduleCollection contentSchedule)
at Umbraco.Cms.Core.Services.ContentService.CreateAndSave(String name, Int32 parentId, String contentTypeAlias, Int32 userId)
at Sss.Mutobo.Core.Services.UserProfileService.CreatePage(IMember member, TeacherProfile profile) in E:_sss\musigschuel.ch\src\Sss.Mutobo.Core\Services\UserProfileService.cs:line 47
at Sss.Mutobo.Core.Controllers.Api.MemberController.SaveTeacherProfile(TeacherProfile profile) in E:_sss\musigschuel.ch\src\Sss.Mutobo.Core\Controllers\Api\MemberController.cs:line 131
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.
I was able to solve my problem. It was because it is a multilanguage solution and I have to make sure that all language versions exist. Yes, we Swiss people have a hard time with our languages ;-).
Cannot create content programmatically
Hello everyone
I'm trying to create content programmatically. I had already done this in previous versions (9 & 10), now I use Umbraco 12.2.0. Now when I call ContentService.CreateAndSave() I get an error that the content cannot be saved with an empty name. However, I pass the following string “roland-schenk” to the method. Are there any new restrictions on the names of a node?
System.InvalidOperationException: Cannot save content with an empty name. at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.EnsureInvariantNameExists(IContent content) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.SanitizeNames(IContent content, Boolean publishing) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.PersistNewItem(IContent entity) at Umbraco.Cms.Core.Cache.DefaultRepositoryCachePolicy
2.Create(TEntity entity, Action
1 persistNew) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase2.Save(TEntity entity) at Umbraco.Cms.Core.Services.ContentService.Save(IContent content, Nullable
1 userId, ContentScheduleCollection contentSchedule) at Umbraco.Cms.Core.Services.ContentService.CreateAndSave(String name, Int32 parentId, String contentTypeAlias, Int32 userId) at Sss.Mutobo.Core.Services.UserProfileService.CreatePage(IMember member, TeacherProfile profile) in E:_sss\musigschuel.ch\src\Sss.Mutobo.Core\Services\UserProfileService.cs:line 47 at Sss.Mutobo.Core.Controllers.Api.MemberController.SaveTeacherProfile(TeacherProfile profile) in E:_sss\musigschuel.ch\src\Sss.Mutobo.Core\Controllers\Api\MemberController.cs:line 131 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.I was able to solve my problem. It was because it is a multilanguage solution and I have to make sure that all language versions exist. Yes, we Swiss people have a hard time with our languages ;-).
is working on a reply...