Sharepoint字段或属性“Body”不存在ServerException

时间:2012-07-09 14:23:17

标签: c# .net sharepoint com

我正在尝试使用C#中的客户端对象模型以编程方式将讨论帖子插入到Sharepoint讨论区列表中。我使用以下代码:

 
var discussionList = sharepointContext.Web.Lists.GetByTitle("Discussion");

    var discussionItem = Utility.CreateNewDiscussion(sharepointContext,  discussionList, "Test");

                discussionItem["Body"           ]    = "Hello world!"
                discussionItem["Author"         ]    = 22;
                discussionItem["Editor"         ]    = 22;
                sharepointContext.Load(discussionItem);
                discussionItem.Update();
                sharepointContext.ExecuteQuery();

但是,每当我运行它时,我都会遇到此异常


    Microsoft.SharePoint.Client.ServerException was unhandled
      Message=Field or property "Body" does not exist.
      Source=Microsoft.SharePoint.Client.Runtime
      ServerErrorCode=-1"

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:1)

问题中的代码不起作用的原因是因为您在调用Update()后调用了SPContext.Load() 。如果你先致电Update(),你会没事的。