I have a sharepoint document library with nested folders. I would like to be able to query the library for all files that have a substring in the name underneath a particular folder.
According to this article, using V2 of the sharepoint online apis are equivalent to using the graph API for the following routes:
https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph
Graph URL |
SharePoint URL |
https://graph.microsoft.com/v1.0/sites |
https://{tenant-name}.sharepoint.com/_api/v2.0/sites |
https://graph.microsoft.com/v1.0/sites |
https://{tenant-name}.sharepoint.com/_api/v2.0/sites |
https://graph.microsoft.com/v1.0/drives |
https://{tenant-name}.sharepoint.com/_api/v2.0/drives |
https://graph.microsoft.com/v1.0/drive |
https://{tenant-name}.sharepoint.com/_api/v2.0/drive |
https://graph.microsoft.com/v1.0/lists |
https://{tenant-name}.sharepoint.com/_api/v2.0/lists |
According to the graph drive search documentation (https://learn.microsoft.com/en-us/graph/api/driveitem-search?view=graph-rest-1.0&tabs=http), the url formula for searching a drive looks like this:
/drives/{drive-id}/root/search(q='{search-text}')
so it seems to me that I should be able to search a sharepoint drive with the following url:
https://{tenant-name}.sharepoint.com/_api/v2.0/drives/{drive-id}/root/search(q='{search-text})'
but I recieve a 500 internal server error with the errors:
{ "error": { "code": "generalException", "message": "General exception while processing" }
I don't believe the URL is malformed since this formula:
https://{tenant-name}.sharepoint.com/_api/v2.0/drives/{drive-id}/root
returns data about the document library.
Do I have the wrong URL, or am I taking the wrong approach? I would love to know if there is another way to do this or if I am misreading your documentation.