我正在尝试将项目添加到 Sharepoint 中的列表中。目前我正在尝试通过 CAML 添加项目
我可以阅读列表并查询列表,但我无法添加到列表中。我看到的所有示例都更新了列表,我希望添加项目的过程应该是相当相似的。
这就是我目前正在测试它的方式。SPLists 是对 http:///_vti_bin/lists.asmx 的 Web 引用
void Test(){
var listService = new SPLists.Lists();
string strBatch ="<Method ID='1' Cmd='New'><Field Name='Title'>Test</Field></Method>";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.SetAttribute("ListVersion", "1");
elBatch.InnerXml = strBatch;
XmlNode ndReturn = listService.UpdateListItems("TestList",elBatch);
Console.Write(ndReturn.OuterXml);
Console.WriteLine("");
}
有人已经在这里问过类似/相同的问题,但没有回答
编辑
这是我得到的错误
<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<Result ID="1,New">
<ErrorCode>0x81020026</ErrorCode>
<ErrorText>The list that is referenced here no longer exists.</ErrorText>
</Result>
</Results>
当我设置网络参考时,它指向了正确的站点,甚至查看了 sharepoint 中的列表以确保它在那里。