pnpcore icon indicating copy to clipboard operation
pnpcore copied to clipboard

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

Open bajce opened this issue 10 months ago • 3 comments

Category

  • [x] Bug

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().

bajce avatar Apr 11 '24 13:04 bajce

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

jansenbe avatar Apr 11 '24 13:04 jansenbe

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);`

bajce avatar Apr 12 '24 06:04 bajce

@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?

jansenbe avatar Jun 03 '24 08:06 jansenbe

@bajce : closing per no response for a long time. If needed, please re-open and provide more context

jansenbe avatar Jul 26 '24 15:07 jansenbe