有没有办法在 Umbraco 8 中以编程方式将 authors/categories 添加到博客 post?

Is there a way to programmatically add authors/categories to a blog post in Umbraco 8?

基本上我从以前的站点导入博客,每个博客 authors/categories post。我能够以编程方式导入博客及其 titles/post 日期,并使用 BlockList 作为正文内容。我们正在使用 USN 主题。

我现在正在尝试使用 Umbraco 8 中的文档将作者和类别添加到 posts。

尝试将作者添加到博客时 post 我使用的成员选择器文档如下所示 -

var guid = Guid.Parse("1l09dfbd-d391-4f07-bfd4-284fcefc99d2"); // Create a variable for the GUID of the page you want to update
var content = contentService.GetById(guid); // ID of your page - Get the page using the GUID you've defined
var authorId = Guid.Parse("a284efc4-e08f-4f7b-a83b-0a4b7m80b45b");
content.SetValue("postAuthor", authorId); 

我可以毫无错误地构建。当转到添加了作者的博客 post 时,我注意到它没有添加作者。如果我随后尝试手动添加作者,则会出现异常 -

“发生错误 找到多个与请求匹配的操作:GetByIds on type Umbraco.Web.Editors.EntityController GetByIds on type Umbraco.Web.Editors.EntityController GetByIds on type Umbraco.Web.Editors.EntityController

异常详细信息 System.InvalidOperationException:找到多个与请求匹配的操作:GetByIds 类型 Umbraco.Web.Editors.EntityController GetByIds 类型 Umbraco.Web.Editors.EntityController GetByIds 类型 Umbraco.Web.Editors.EntityController"

我要以正确的方式添加作者吗?使用成员选择器 属性 编辑器时,我无法找到有关此错误的任何信息。

我也尝试过向 post 添加类别,我假设我需要使用 Multinode-Treepicker 来添加它们。我走的路对吗?

我的文件结构是这样的。

Home
+Blog
++Categories
++Authors
++Posts

提前感谢任何advice/tips。

能够得到这样的作者

string somestring = Convert.ToString(contentService.GetByLevel(4).Where(x => x.Name == authorUsername).FirstOrDefault().Key).Replace("-", String.Empty);
content.SetValue("postAuthor", $"umb://document/{somestring}");