将项目添加到列表时,出现错误 Invalid data has been used to update the list item。您尝试更新的字段可能是只读的

When adding item to List, I get error Invalid data has been used to update the list item. The field you are trying to update may be read only

我正在使用客户端 Object 模型来更新 SharePoint 上的列表。

列表非常简单,只有 3 列([标题]、[作者]、[出版年份])

[Title]为默认添加的标准栏目,

[Author]是我自己的专栏,它是一个字符串字段(它不是指向User,它只是纯文本)

和 [Year Published] published 是一个数字。

所有字段都标记为必填。

string strUrl = "http://server/sites/training";
using (SPSite oSite = new SPSite(strUrl))
{
    using (SPWeb oWeb = oSite.OpenWeb())
    {
        SPList list = oWeb.Lists["Books"];
        SPListItem book = list.AddItem();
        book["Title"] = "SQL Server Internals";
        book["Author"] = "Mc Fredy";
        book["Year Published"] = 2015;
        book.Update();
    }
}

我在 book.Update();

上遇到异常

Invalid data has been used to update the list item. The field you are trying to update may be read only.

我查看了我在网上找到的所有内容,但没有找到任何答案。 请指教

Author 是内部 Sharepoint 字段,其中包含有关记录创建者(显示名称 Created By)的信息,您无法更改它。查看 this post 以找出您的字段的内部名称并尝试使用它。