sp-dev-docs
sp-dev-docs copied to clipboard
Search API returns 0 results when logged in with Application Permissions
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
SharePoint REST API
Developer environment
Windows
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [ ] 💥 Microsoft Edge
- [ ] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [X] other (enter in the "Additional environment details" area below)
Additional environment details
.NET Console appliction with plain HTTP Client, CSOM, Pnp.PowerShell .Net Console application uses Confidential- en PublicClientApplication to retrieve application- or delegated permissions access token.
Describe the bug / error
As of Agust 26 SharePoint Search started returning either results or no results from time to time. After the weekend, it started returning 0 results continuously.
We troubleshooted the error, and in the beginning we had 0 results when using RefinableStrings, but results when searching on other properties. At the moment, neither search requests returns results.
Further troubleshooting showed that the issue only occurs when using AppId/Certificate authentication, and no issues when using Delegated permissions (letting a user log in).
This is fine for end-user applications, but not for background services like f.i. Runbooks.
All was working fine until August 26.
Our tenant is not the only one having this issue: https://techcommunity.microsoft.com/t5/sharepoint-developer/search-api-with-application-permissions-returns-no-results/m-p/3620241
Steps to reproduce
- Create any application with application permissions (Azure Portal, App registration). Using a certificate or secret, neither works.
- Give it all application and delegated permissions for SharePoint, and Grant Admin consent.
- Get access token with a ConfidentialClientApplication (application permissions)
- Request an HTTP request to tenant.sharepoint.com/_api/search/query (GET) or tenant.sharepoint.com/_api/search/postquery (POST)
- For certain lists (not all!) you get 0 results
- Get access token with a PublicClientApplication (delegated permissions)
- Request an HTTP request to tenant.sharepoint.com/_api/search/query (GET) or tenant.sharepoint.com/_api/search/postquery (POST)
- For the same search query, you get results.
Expected behavior
The results that were given by using the Delegated Permissions, should also be given by the Application Permissions.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We also have the same problem on multiple tenants without having touched anything, are there any updates?
Maybe good to know: I have a list, on which I try to find listitems. The list returns 0 results, searching using multiple options (no ManagedProperty, on RefinableString, ...) when using Application Permissions. Except for 1 listitem: this one I do find, with both permissions (application, delegated). I accidentally found out. I tried to figure out what is different on this listitem, but couldn't find anything.
Edit: the only difference I see, is that the Author of that one listitem is an actual user: | upn | display_name | some_large_guid i:0#.f|membership|upn The other listitem's Author's are an app: | App name | some_large_guid i:0i.t|some guid|UPN_of_app
Edit 2: I created a new listitem myself (not by the app above), and that one I can find as well, by any authentication.
Bump ...
@StevenDeRoover fix was deployed 9/30, can you verify that it is now working?
we still have the same problem
@devromano Can you please open a support ticket for your case and provide trace logs when you log it?
@devromano Can you please open a support ticket for your case and provide trace logs when you log it?
Hello Mikael
Hate to tell you this, but opening a support ticket is sadly not the way to go. First line support knows nothing about API's, and this issue, for them, is out-of-scope.
This I had to learn by sending a load of e-mails back and forth with Microsoft Support.
Shortly: when it comes to Microsoft Support, you are lost when it comes to technical issues, where only out-of-the-box issues are covered.
@StevenDeRoover Please do it and share the id with me in some way.