Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Unknown server error when accessing Search api via REST

$
0
0

When trying to access the SharePoint search service via REST, I always get an internal server error with no information about the cause of the problem.

My SharePoint app uses app-only permissions, and includes search permissions as follows:
  <AppPermissionRequests AllowAppOnlyPolicy="true">
    <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="Write" />
    <AppPermissionRequest Scope="http://sharepoint/social/tenant" Right="Read" />
    <AppPermissionRequest Scope="http://sharepoint/search" Right="QueryAsUserIgnoreAppPrincipal" />
  </AppPermissionRequests>
I see the search permission listed when installing the app.

I know I'm getting a valid bearer token, because all of my other requests work fine. Here is the request I'm making that returns the error:

REQUEST:
$ curl -H "Authorization:Bearer abcABC...f1-iYrm-efhQ" https://<domain-my>.sharepoint.com/_api/search/query
where <domain-my> is the SharePoint site that I'm accessing. I've also tried this request with all combinations of headers, including Accept, Content-Type, odata, and even including the request digest. I've also tried adding query parameters, and using POST with the query in the message body. However, this is always the response I receive:

RESPONSE:
<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-1, Microsoft.Office.Server.Search.REST.SearchServiceException</m:code><m:message xml:lang="en-US">An unknown error occurred.</m:message></m:error>

If I log in to SharePoint I can make a get request to /_api/search/query and it returns a non-error response. What is causing the problem with my REST request? Is there any way to get more information from the server? This is SharePoint online, so I don't have access to the server.

Thanks!


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>