I am getting 401 unauthorized error when calling a sharepoint search rest api (http://:/_api/search/query?querytext=) from a .net application using claims based authentication.
My request and error as below
private void GetSearchResponse(HttpWebRequest httpWebRequest)
{
try
{
using (var httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse)
{
using (var stream = httpWebResponse.GetResponseStream())
{
ProcessSearchResponse(stream);
}
}
}
catch (WebException ex)
{//catch and log the error
}
stack trace : "{\"error\":{\"code\":\"-2147024891, System.UnauthorizedAccessException\",\"message\":{\"lang\":\"en-US\",\"value\":\"Access denied. You do not have permission to perform this action or access this resource.\"}}}"
Thanks a lot in advance for your help and time.