3
Answers

Unauthorized error in KeywordQuery search object SP2013

sumit kumar

sumit kumar

9y
399
1
I am getting UnauthorizedAccessException while creating KeywordQuery object. I have tried with all the overloaded method for KeywordQuery in SharePoint 2013.  I am able to create SPSite object.
 
Below is the code:
 
using (SPSite site = new SPSite(url))
{
SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(site));
using (KeywordQuery keywordQuery = new KeywordQuery(site))//Unauthorised Access Exception on this line
{
//doing something with KeywordQuery object
}
 
Answers (3)