Im working on Sharepoint 2013 Community site template. When I manually create a discussion in discussions list liking and replying features are working fine, but when I programmatically add a dicussion in discussions list its giving the following error "Value does not fall within the expected range".
This is the C# code im using to add an item in discussions list.
using (SPSite site = new SPSite("http://site-url")) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["Discussions List"]; SPListItemCollection listItemCln = list.GetItems(list.Views["Management"]); SPListItem item = list.Items.Add(); item["Title"] = "New Post"; item["Body"] = "Body of the post"; item.Update(); } }
I checked the log files of sharepoint also it gave the follwing error
Failed to cache field with id "{69062c99-d89f-4162-bbc5-b1acf8bfe123}", overwrite=0
at Microsoft.SharePoint.Utilities.SPUtility.CreateNewDiscussionReply(SPListItem parent)
at Microsoft.SharePoint.ServerStub.Utilities.SPUtilityServerStub.InvokeStaticMethod(String methodName, XmlNodeList xmlargs, ProxyContext proxyContext, Boolean& isVoid)
at Microsoft.SharePoint.Client.ServerStub.InvokeStaticMethodWithMonitoredScope(String methodName, XmlNodeList args, ProxyContext proxyContext, Boolean& isVoid)]
Can anyone help me on this please