sharepointsharepoint-clientobjectsplistitem

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


I'm using Client Object Model to update a list on SharePoint.

The list is very simple, it only has 3 columns ([Title], [Author], [Year Published])

[Title] is the standard column added by default,

[Author] is my own column and it is a string field (it's not pointing to User, it's just plain text)

and [Year Published] published is a Number.

all fields are marked as required.

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();
    }
}

I get exception on book.Update();

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

I looked into everything I found on web but did not find any answer. Please advise.


Solution

  • Author is internal Sharepoint field which contains information about who created record (display name Created By) and you cannot change it. Checkout out this post in order to find out internal name of your field and try to use it instead.