We are building a SharePoint files navigation experience with the Microsoft Graph API. We are including a feature in order to be able to copy/paste a link and let the app resolve the container or item.
The API provides provides a shared
endpoint which is able to resolve various links:
- Links to the site collection root
- Links to subsites
- Links to document library root
- Links to folders
- Links to files
Unfortunately we are not able to get specific properties that define the type of the item.
It seems we will need to perform two queries:
/shares/<id>/driveItem
/shares/<id>/site
We then combine the results of both endpoints to deduce the type of item.
If driveItem
errors out, we know it is either the root of a site collection or a subsite.
If driveItem
yields a result, it contains either a folder
property, or a file
property.
Although this works, it takes two calls. It would be great if we could just query /shares/<id>
with some additional query parameters to get the type and the details of the item.
Any suggestions?
Documentation: https://learn.microsoft.com/en-us/graph/api/shares-get