I received error when I sent search sharepoint api.
api url:
https://johnscoca.sharepoint.com/_api/Search/Query?QueryText='contentclass:STS_Site contentclass:STS_Web NOT IsExternalContent:true'&SourceId='8413cd39-2156-4e00-b54d-11efd9abdb89'&EnableQueryRules=false&EnableStemming=false&TrimDuplicates=false&StartRow=0&RowLimit=50&SelectProperties='Title,Path,Description,contentclass,WebTemplate,LastModifiedTime'
document:
https://learn.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview
api 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">We didn't understand your search terms. Make sure they're using proper syntax.</m:message>
</m:error>
It has been found that removing the QueryText from the param or passing an empty string allows the API to succeed.
Then, I tried to send graph api (search sharepoint api), getting error "generalException"
api url:
https://graph.microsoft.com/v1.0/sites?search=*&$top=1000
document:
https://learn.microsoft.com/en-us/graph/api/site-search?view=graph-rest-1.0&tabs=http
api response:
{
"error": {
"code": "generalException",
"message": "General exception while processing",
"innerError": {
"date": "2024-05-07T06:49:10",
"request-id": "9b1286dc-bd8f-4650-9557-d21f6734237c",
"client-request-id": "9b1286dc-bd8f-4650-9557-d21f6734237c"
}
}
}
What is the reason and how can it be resolved? Thanks.