Crawl in sharepoint 2010 fails with an error
The SharePoint item being crawled returned an error when requesting data from the web service. ( Error from SharePoint site: Data is Null. This method or property cannot be called on Null values. )
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
Crawl in sharepoint 2010 fails with an error
The SharePoint item being crawled returned an error when requesting data from the web service. ( Error from SharePoint site: Data is Null. This method or property cannot be called on Null values. )
If the Sharepoint Object model is used to add a new group to the GroupCollection of a site and the value passed to Description parameter of the SPGroup is null then this issue will occur.
Sample Code which can cause the problem
-----------------------------------------------------
using (SPSite oSite = new SPSite(textBox1.Text))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPGroupCollection oGroupColl = oWeb.SiteGroups;
SPUser oUser = oWeb.AllUsers["domain\\user"];
oGroupColl.Add("Testing Group", oUser, oUser, null);
}
}
Use the Object model to get all the SPGroup whose Description property is set to null and update the value with a string value.
Sample code which will fix the issue
-------------------------------------------
using (SPSite oSite = new SPSite(textBox1.Text))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPGroupCollection oGroupColl = oWeb.Groups;
foreach (SPGroup oGroup in oGroupColl)
{
if (oGroup.Description == null)
{
oGroup.Description = "String";
oGroup.Update();
}
}
}
}
If we rerun the crawl again the issue would be resolved.
Keywords: vkball, kb