Your intellisense is picking up the wrong method signature. Therefore you are referencing an incorrect library.
using System;
using System.Web.Mvc;
using Umbraco.Core.Services;
using Umbraco.Web.Models;
public class TestController : Umbraco.Web.Mvc.RenderMvcController
{
public IContentService _contentService { get; set; }
public TestController(IContentService contentService)
{
_contentService = contentService;
}
public override ActionResult Index(ContentModel model)
{
var parentId = new Guid("3cce2545-e3ac-44ec-bf55-a52cc5965db3");
var request = _contentService.Create("test", parentId, ContentPage.ModelTypeAlias);
_contentService.SaveAndPublish(request);
return View();
}
}
I think your using is incorrect and you are referencing Umbraco 7 libraries?
Create new content nodes programmatically in Umbraco 8.
Hello,
In Umbraco 7 I used the following code to generate code programmatically from C# (controller)
And following is the code for the same
Now in Umbraco 8
it is asking for
getting error "Can not convert 'int' to 'Umbraco.Core.Uid' ".
Have searched a lot, but can't find anything for Umbraco 8.
So now the question is How we can create a node from a controller in Umbraco 8?
Thanks BJ
You need to pass in the Guid of the parent node.
To get the guid of node you can now access it via the "Key" property of your node.
Or go into the backend and find it on the info tab:
Thank Matt,
I have tried passing the same but getting error "Can not convert from System.Guid" to Umbraco.Core.Udi"
Any suggestion?
Thanks BJ
Your intellisense is picking up the wrong method signature. Therefore you are referencing an incorrect library.
I think your using is incorrect and you are referencing Umbraco 7 libraries?
I have the problem. Did you solve this BJ Patel?
Hi iNETZO,
Yes, Following is my code. maybe it will help you.
Hope it may be helpful to you.
Thanks BJ Patel.
Hello,
Can we Create Language variants nodes programmatically in Umbraco 8 ?
have you found out how to Create Language variants nodes programmatically in Umbraco 8 ????????????????
Hi Hassan;
Im new with umbraco 8; but i found a post with info related to 'culture' properties that could be useful:
Content Variant APIs examples:
var c2 = new Content("hello world", myContentType, "en-US");
//this will set the Spanish name
c2.SetCultureName("hola", "es-ES");
var result = ContentService.SaveAndPublish(c2); //will publish all cultures
source: https://github.com/umbraco/Umbraco-CMS/issues/4452#issuecomment-462207275
is working on a reply...