Programatically Creating Content in Umbraco 14
t
I am attempting to use the content service in an umbraco razor template (awful idea and bad practice I know). I have had success in the past using the content service where you create a node and specify name, parentId, contentTypeAlias. In Umbraco 14 I do the same thing, I get no errors, no log messages indicating failure to create/success, etc. I even took the code straight from : https://docs.umbraco.com/umbraco-cms/reference/management/services/create-content-programmatically and I'm having no luck. Any ideas?
Save(IEnumerable someContent) works and only after calling save does SaveAndPublish(IContent aPieceofContent) work
scratches head
s
Yup you've definitely found a bug there. I can recreate. Searched the bug tracker and cannot find so created a new one https://github.com/umbraco/Umbraco-CMS/issues/16637
d
Hi there! I have manged to programmatically create content with the content service in Umbraco 14. Most notably: it's now mandatory to call
.Save()
before
.Publish()
. You may check this piece of code in my content generator package: https://github.com/Infocaster/ContentGenerator/blob/v14/main/ContentGenerator/Request/GenerateContentRequestHandler.cs#L79
12 Views