admin 管理员组文章数量: 1086019
I have a SharePoint list with the following columns Name, Date, Folder
For some reason, whenever I am updating the third column Folder
, I get the error Server Exception: Invalid Request
.
When I remove the code where it updates this third column, then there is no error.
Why does it keep throwing an error when I am trying to update more than 2 fields for a List Item? Name
and Date
fields update fine, but every time it gets to Folder
field and tries to assign a value to it, the error is thrown. It doesn't matter what type the column is. For simplicity, I just made it a text
column and am just assigning a string to it.
List<Dictionary<string, string>> listItems = new List<Dictionary<string, string>>();
foreach (var item in itemResults)
{
CreateFolderInSharepointDocumentLibrary(SP_DOCUMENT_LIBRARY_ROOT, sharePointFolderName);
Dictionary<string, string> listItemDetails = new Dictionary<string, string>()
{
{ LIST_TITLE_KEY, item.Subject },
{ LIST_DATE_KEY, formattedDate },
{ LIST_FILE_KEY, folderUrl }
};
listItems.Add(listItemDetails);
}
...
...
foreach (var item in listItems)
{
CreateListItem(MY_LIST_NAME, item);
}
public void CreateListItem(string listName, Dictionary<string, string> item)
{
using (var clientContext = GetSharePointClientContext())
{
Web web = clientContext.Web;
clientContext.Load(web.Lists, lists => lists.Include(list => list.Title, list => list.Id));
clientContext.Load(web, a => a.ServerRelativeUrl);
clientContext.ExecuteQuery();
List targetList = clientContext.Web.Lists.GetByTitle(listName);
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem oListItem = targetList.AddItem(itemCreateInfo);
oListItem["Name"] = "Test One";
oListItem["Date"] = "Test Two";
oListItem["Folder"] = "Test Three"; // --> Error always here. No error when removing
oListItem.Update();
clientContext.ExecuteQuery();
}
}
When ever it gets to here oListItem["Folder"] = "Test Three";
it keeps crashing and throwing the error. When I uncomment, program runs fine.
本文标签:
版权声明:本文标题:c# - net framework sharepoint online csom console app crashes when updating more than two items in a list item - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744047755a2524442.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论