SharePoint Search Query Returning Empty Table
Hello,
I'm trying to run a search query to get ViewsLifeTime & ViewsLifeTimeUniqueUsers for pages in our SharePoint tenant, however the table being returned for each query is empty.
ctx_auth = AuthenticationContext(url)
ctx_auth.acquire_token_for_app(client_id, client_secret)
ctx = ClientContext(url, ctx_auth)
results = ctx.search.query(query_text="path:{url of page}").execute_query()
If I follow down results.value.PrimaryQueryResult.RelevantResults.Table there are no rows / key/value pairs, and if I attempt using the get_property() func to isolate a property, it does not find it.
If the query is executed in a browser (e.g. https://{site}.sharepoint.com/_api/search/query?querytext='path:{url of page}') this returns the required data in the SimpleDataTable table
Looking at other issues I also tried:
search = SearchService(ctx)
request = SearchRequest(query_text="path:{url of page}")
result = search.post_query(request).execute_query()
However this returns an error of ('-1, Microsoft.Data.OData.ODataException', "Incompatible type kinds were found. The type 'Microsoft.Office.Server.Search.REST.SearchRequest' was found to be of kind 'Complex' instead of the expected kind 'Primitive'.", '400 Client Error: Bad Request for url: {url of page}).
Am I missing something?
Cheers,
James