2

We have a requirement to retrieve all sharing links from particular document of document library via SharePoint CSOM C#. We are able to get Anonymous sharing links and Organization Sharing links using below piece of code:

var sharingInfo = ObjectSharingInformation.GetObjectSharingInformation(clientContext, listItem, false, true, false, true, true, true, true);                
clientContext.Load(sharingInfo);
clientContext.Load(sharingInfo.SharedWithUsersCollection);
clientContext.ExecuteQuery();

// Getting Anonymous Edit Link from sharing object  
string anonymousEditLink = sharingInfo.AnonymousEditLink;
Console.WriteLine(anonymousEditLink);

// Getting Anonymous View Link from sharing object  
string anonymousViewLink = sharingInfo.AnonymousViewLink;
Console.WriteLine(anonymousViewLink);


if (sharingInfo != null && sharingInfo.SharingLinks != null)
{
    // Looping all sharing links from ObjectSharingInformation  
    foreach (SharingLinkInfo sharingLinkInfo in sharingInfo.SharingLinks)
    {
        try
        {
            if (!string.IsNullOrEmpty(sharingLinkInfo.Url))
            {
                Console.WriteLine("URL: {0}", sharingLinkInfo.Url.ToString());
            }
        }catch(Exception)
        {}
    }
}

But with above code, I'm not able to get these Specific People type sharing links from the list item via CSOM C# as shown in below image: enter image description here enter image description here

Please provide me some guidance to get these type of Sharing links using CSOM C# code.

1 Answer 1

2

Specific People type is also known as Flexible sharing link.

We can get sharing links related information for documents from Sharing Links list. Please see this answer I added here: How to get Shared by and Shared To properties of Sharing links from a document from SharePoint Online using CSOM C#

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.