0

Our goal is to query the Sharepoint Search API and fetch all files from OneDrive (my drives/personal sites) where the search input exists in the content. We are using the following query:

POST https://[tenantName].sharepoint.com/_api/search/postquery 
Body: { "request": { "Querytext": "abc", "RefinementFilters": [ "Path:\"https://[tenantName]-my.sharepoint.com/personal*\"" ] } } 

But no results are being returned, when we remove the RefinementFilters, search api is returning responses from sharepoint sites, but we want search on Onedrive only. we have added all the permissions required, to use this api (mentioned here : https://docs.microsoft.com/en-gb/archive/blogs/vesku/using-add-in-only-app-only-permissions-with-search-queries-in-sharepoint-online).

Are we missing any anything here? is there special configuration required for onedrive? Any help will be appreciated. TIA.

1
  • I cannot test the syntax but I believe you missed refiners='Path' part
    – Mark L
    Sep 29, 2020 at 4:26

1 Answer 1

0

Your query require Refiners parameters to match with RefinementFilters:

Body: { "request": { "Querytext": "abc", 
"Refiners":"Path",
"RefinementFilters": [ "Path:\"https://[tenantName]-my.sharepoint.com/personal*\"" ] } } 
8
  • It didn't work, actually none of the Onedrive(my site) files are being returned Even If I remove the the RefinementFilters, the response does not returns the onedrive files where this text exist, it ONLY returns the other sharepoint site's files.
    – ShahtajK
    Sep 29, 2020 at 10:20
  • @ShahtajK do you get any Onedrive file result using the existing search box?
    – Mark L
    Sep 30, 2020 at 3:33
  • Yes, I'm able to search on OneDrive from UI, but not via this search api. I have added the required tenant level permission on this application, is there any other permission required to access it?
    – ShahtajK
    Sep 30, 2020 at 5:43
  • I tested with PowerShell query my SPO site and it works. I think you got problem on other parts, not the query.
    – Mark L
    Sep 30, 2020 at 6:15
  • Yes, as I'm able to get responses from sharepoint sites with the same query (after removing filters), but can you please check the permissions and tell me if these xml permission is enough to run this query for one drive ? do we need any other permission to search on onedrive ?
    – ShahtajK
    Sep 30, 2020 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.