Forum Discussion

Facundo_Soler's avatar
Facundo_Soler
Copper Contributor
Feb 19, 2024

Need Help: Accessing 'Shared' DriveItem Property in SharePoint Without Delta API

Hello everyone!

I am attempting to retrieve all root drive items from a folder, including the 'Shared' property of each drive item. However, even when I explicitly include the 'shared' attribute in my QueryOption object, it does not seem to reflect any changes. It always returns an object with the "Scope" property set to "user", even if the default permissions have not been altered for the item.

Interestingly, when utilizing the Delta API, the behavior observed is that only items with set permissions (beyond the default ones) return a valid, non-null "Shared" object with the "Scope" property set to 'user'. Conversely, items without set permissions (i.e., default permissions only) return a null "Shared" object. This difference effectively helps in determining whether each item was actually shared. 

The reason I need to specifically fetch a list of ROOT drive items for a folder, rather than utilizing the Delta API to track changes (which could potentially traverse through sub-folders and their children/grandchildren on an initial query), is due to the requirement to perform a clean fetch of all items for specific SharePoint site libraries. These libraries often contain thousands of subfolders and files, while we are only interested in the root items of a particular folder for caching purposes. The Delta API variant could potentially take over an hour per folder to traverse through, which is not feasible for our needs. Unless there's a way to restrict Delta API calls to only directly access a root folder's children, I'm seeking alternative solutions.

 

Here is my Select query option (C#) :

new QueryOption("select", " id, name, createdDateTime, lastModifiedBy, lastModifiedDateTime, size, parentReference, permissions, sharepointIds, file, eTag, webDavUrl, deleted, folder, shared")

As you can see I've included the 'shared' attribute in this query.

My Graph API request (C#) :

driveItemRequest.ItemWithPath(formattedPath).Children.Request(options)

 

Is there any way I can obtain the desired "Shared" property without resorting to the Delta API for all root items in a folder? Alternatively, is there a method involving Permissions endpoints that I can use to achieve a similar result? At this stage, I am only in need of a boolean flag indicating whether permissions have been modified or not, as mentioned earlier.

 

Thanks in advance to anyone who can offer any guidance on this matter !

 

Kind regards,

Facundo. :smile:

No RepliesBe the first to reply

Resources