// Create a variable for the GUID of the parent page - Catalogue, where you want to add a child item.
var parentId = Guid.Parse("b6fbbb31-a77f-4f9c-85f7-2dc4835c7f31");
// Create a new child item of type 'Product'
var demoproduct = ContentService.Create("Microphone", parentId, "product");
I get the error: CS1503 Argument 3: cannot convert from 'System.Guid' to 'Umbraco.Cms.Core.Udi' on the parentId.
Cannot convert from 'System.Guid' to 'Umbraco.Cms.Core.Udi'
When I use a surfacecontroller and the documentation here for content creation: https://docs.umbraco.com/umbraco-cms/reference/management/services/contentservice/create-content-programmatically
I get the error: CS1503 Argument 3: cannot convert from 'System.Guid' to 'Umbraco.Cms.Core.Udi' on the parentId.
Anybody know why this error comes?
I am using Umbraco 13.
Are you injecting ContentService into your controller?
Something like:
Also ensure the Guid exists in your content and not just this sample one?
Ah, great, I see the error. I was using _contentService.CreateContent - which specifically asked for a Umbraco UID.
Your code doesn't do that it seems. When I use
_contentService.Create, it works superb.
I don't know why there are two different methods there. I guess there is a reason somewhere.
Thanks :-)
is working on a reply...