Hi Hew thanks for your quick reply. But I have solved my problem in the meantime. 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 ;-).
post = _contentService.Create(postName, parent, "forumPost");
if (post.AvailableCultures.Any())
{
foreach (var language in languages)
{
post.SetCultureName(postName,language.IsoCode);
}
}
programmatically create content not working
This seems to be an old issue that I are having trouble with.
Asking again as all the posts are for old version of umbraco.
I'm running v12.2.0 )Latest version.
Have followed this documentation https://docs.umbraco.com/umbraco-cms/reference/management/services/contentservice/create-content-programmatically witch was last updated 16hrs ago at time of writing this post.
The only difference I are running the code from server side in a hangfire scheduled task.
I get the parent document
IPublishedContent catFolder = query.ContentAtRoot().DescendantsOrSelfOfType("IBDExypnosLandingPage").FirstOrDefault().FirstChildOfType("IBDExypnosCategoriesFolder");
create the IContent
// assign parent id. Guid parentId = catFolder.Key;
// create content var newCatagory = _contentService.Create(Name, parentId, "IBDExypnosCategoriesPage");
Up until here everything is working fine. 1st issue
these line generate this error: Variation null,null is not supported by the property type.
have also tried:
newCatagory.SetValue(propertyTypeAlias: "onPageTitle", "hello", segment: null);
2nd issue
this line generate this error: Cannot save content with an empty name.
Anybody with some ideas
Are you sure that the 'Name' variable is not empty here?
If the document type is variable by culture don't forget to add the name for each culture.
I have the exact same problem on 12.2.0. Have you found a solution yet?
I think you need to pass a udi not id for the parent
Hi Hew thanks for your quick reply. But I have solved my problem in the meantime. 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 ;-).
That was going to be my next suggestion :D
is working on a reply...