pnp / pnpcore

The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
https://aka.ms/pnp/coresdk/docs
MIT License
288 stars 188 forks source link

Error Accessing Sharing Links on List Items: Property SiteId Not Loaded #1440

Open bajce opened 3 months ago

bajce commented 3 months ago

Category

Describe the bug

When attempting to use the item.File.GetShareLinks() method on items within a List (not a Document Library) which have sharing links, I encounter an error stating that the Property SiteId was not yet loaded. I have tried various methods to explicitly load the SiteId property but none have resolved the issue.

Steps to reproduce

  1. Create a SharePoint List (not a Document Library) and create items with sharing links.
  2. Attempt to retrieve sharing links for the file using the PnP Core SDK method item.File.GetShareLinks().
jansenbe commented 3 months ago

@bajce : can you show me how you've loaded the item?

bajce commented 3 months ago

Im loading Items using List#LoadItemsByCamlQuery. But the exception occurs only when loading items of List (not Document Library). As a workaround im currently loading the Sharing Link permissions directly via Graph API.


 list.LoadItemsByCamlQuery(new CamlQueryOptions()
                    {
                        ViewXml = @"<View Scope='RecursiveAll'>
                                        <ViewFields>
                                               <FieldRef Name='FileLeafRef'/>
                                               <FieldRef Name='FileRef'/>
                                               <FieldRef Name='FileDirRef'/>
                                               <FieldRef Name='ItemChildCount'/>
                                               <FieldRef Name='FolderChildCount'/>
                                               <FieldRef Name='UniqueId'/>                              
                                               <FieldRef Name='ParentUniqueId'/>
                                               <FieldRef Name='Title'/>
                                               <FieldRef Name='FSObjType'/>
                                            </ViewFields>
                                       <RowLimit Paged='TRUE'>500</RowLimit>
                                   </View>",
                        DatesInUtc = true,
                        PagingInfo = nextPage
                    },
                    item => item.UniqueId,
                    item => item.FileSystemObjectType,
                    item => item.FieldValuesAsText,
                    item => item.File.QueryProperties(f => f.UniqueId, f => f.SiteId, f => f.VroomItemID, f => f.VroomDriveID),
                    item => item.Folder.QueryProperties(f => f.UniqueId),
                    item => item.HasUniqueRoleAssignments);`
jansenbe commented 1 month ago

@bajce : we did not yet implement GetShareLinks for list items as back then the needed Graph APIs were not available. I did cross check on the Graph APIs and today we've not shipped /permissions on a list item (e.g. sites/b56adf79-ff6a-4964-a63a-ff1fa23be9f8/lists/91bb170e-0ef0-4062-86f9-e5dbe8d047bd/items/1/permissions). How are you loading the sharing link permissions via Graph?