I have Umbraco 16 running and I after some work I was able to publish programmatically to a rich text in a block list on a document. I started off by adding clean starter kit which has been a big help getting the CMS working. The issue I’m having is when a run the code below and I go to the content, it displays draft on the rich text. If I click create on the rich text it fixes the issue. I’ve got to import 500+ posts and I can’t go into every one to fix them manually. Any help would be greatly appreciated.
Here’s the code I’m using to achieve setting the rich text value inside the blocklist:
var parentId = Guid.Parse(“8b97891b-bb88-4c50-827d-a458c3c2b7bb”);
var myValue = “Author bio test text Super Excited About it!”;
var dictionaryUdi = new List<Dictionary<string, string>>();
var contentUdi = Guid.NewGuid().ToString(); //new GuidUdi(“element”, System.Guid.NewGuid());
var blocklist = new Blocklist();
var values = new List {
new() {
editorAlias = “Umbraco.RichText”,
alias = “content”,
value = myValue } };
dictionaryUdi.Add(new Dictionary<string, string> { { “contentKey”, contentUdi.ToString() } });
blocklist.layout = new BlockListUdi(dictionaryUdi);
blocklist.settingsData = ;
blocklist.contentData =
[ new ContentData { contentTypeKey = importContent.UmbBlockListContentKey,
key = contentUdi,
values = values } ];
var content = _contentService.Create(“Test Author”, parentId, “Author”);
content.SetValue(“title”, “my test title”);
content.SetValue(“metaDescription”, “my meta description”);
content.SetValue(“contentRows”, JsonConvert.SerializeObject(blocklist));
_contentService.Save(content);
_contentService.Publish(content, [“*”]);
I’m using the following model:
public class Blocklist
{
public BlockListUdi layout { get; set; }
public List contentData { get; set; }
public List<Dictionary<string, string>> settingsData { get; set; }
}
public class BlockListUdi
{
[JsonProperty(“Umbraco.BlockList”)]
public List<Dictionary<string, string>> contentUdi { get; set; }
public BlockListUdi(List<Dictionary<string, string>> items)
{
this.contentUdi = items;
}
}
public class ContentData
{
public string contentTypeKey { get; set; }
public string key { get; set; }
public List values { get; set; }
}
public class ValueRow
{
public string editorAlias { get; set; }
public object culture { get; set; }
public object segment { get; set; }
public string alias { get; set; }
public string value { get; set; }
}

