I'm trying to use the Content Service to create a new node when a page has been published.
I'm current creating the new node using the following code
IContent c = contentService.Create("Test Name", Guid, "contentPage", author.Id);
contentService.SaveAndPublish(c);
However, when I hit the SaveAndPublish function I get the error:
"An exception of type 'System.InvalidOperationException' occurred in Umbraco.Core.dll but was not handled in user code
Additional information: Cannot save content with an empty name."
I've tried setting the name different ways, and also tried setting the publishedName in case this is what it was having issues with but I've had no joy.
Does anyone have an idea what could be causing this?
Content Service - Cannot Create Node
Hi,
I'm trying to use the Content Service to create a new node when a page has been published.
I'm current creating the new node using the following code
However, when I hit the SaveAndPublish function I get the error:
"An exception of type 'System.InvalidOperationException' occurred in Umbraco.Core.dll but was not handled in user code Additional information: Cannot save content with an empty name."
I've tried setting the name different ways, and also tried setting the publishedName in case this is what it was having issues with but I've had no joy.
Does anyone have an idea what could be causing this?
Hi Andrew,
It seems that it is necessary to set the name for at least one culture. Do you have more that one cultures configured?
Then you can try this code:
Brilliant, thanks Corné, that's done the job! Thanks for your help :)
is working on a reply...