问题
DriveItem Search does not seem to be possible in an Office 365 group context, despite the documentation mentioning it should be supported:
GET /groups/{group-id}/drive/root/search(q='{search-text}')
Steps to reproduce (e.g. in the Graph Explorer):
- create
newFileTest.docxin the root of your GROUP folder - Search for the file:
https://graph.microsoft.com/v1.0/groups/{GROUP_ID}/drive/root/search(q='newFileTest.docx')- returns 0 items - create
newFileTest.docxin the root of your PERSONAL folder; - Search for the file:
https://graph.microsoft.com/v1.0/me/drive/items/root/search(q='newFileTest.docx')- returns 1 item
Happy to provide more info if needed.
回答1:
I've tried the following (with my O365 group):
https://graph.microsoft.com/v1.0/groups/cfb5e170-36b0-4156-b17b-4b6bc2ddd777/drive/items/root/search(q='t.xlsx')
and it's returning one (as it should).
回答2:
this is most probably due to insufficient permission. You may not have Read Write Permission for Groups.
You can try this .
回答3:
Thanks for taking the time to reply everyone! Turns out the problem is with one of my sites that I'm trying to perform a search in. Searching in the SharePoint UI also doesn't work on this site, and it's not visible in the list of Team Sites in OneDrive. A different Team Site is visible in this list, and searching in that Site works in both the SharePoint UI and Graph API. Will open a support ticket with Microsoft about this. Thanks again!
The affected Team Site:
The working Team Site:
来源:https://stackoverflow.com/questions/55727839/drive-search-not-working-in-office-365-group