Share a file with external users using anonymousAccess by using sharepoint REST API

john john 946 Reputation points
2023-05-11T22:36:23.74+00:00

After doing some research, i reached out the i can do the following POST request which will allow me to share a file with external users using anonymousAccess:-

Method:- POST

URL:- _api/web/Lists('ListGUID')/GetItemByID('1')?['ID']}')/Sharelink

Body:-

{

    "request":{
        "createLink":true,
        "settings":{
            "allowAnonymousAccess":true,
            "linkKind":6,
            "role":1,
            "restrictShareMembership":false,
            "updatePassword":true,
            "password":"***",
            "scope":0
        }
    }
}

now in general the above will allow me to create an anonymous link with a password and with read-only permission, but i am confused on the other parameters, which are :-

  1. "linkKind"
  2. "restrictShareMembership"
  3. "updatePassword"
  4. "scope":0

so what are those parameters and what they represents inside the UI:-

User's image

Thanks

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,989 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,754 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ChengFeng - MSFT 5,015 Reputation points Microsoft Vendor
    2023-05-12T05:06:44.17+00:00

    Hi @john john ,

    Here's an explanation of the parameters you mentioned:

    "linkKind": This parameter specifies the type of link that is created. The possible values are:

    0 - View

    1 - Edit

    2 - Shared Folder

    3 - Organization View

    4 - Organization Edit

    5 - Anonymous View

    6 - Anonymous Edit

    "restrictShareMembership": This parameter determines whether sharing is restricted to users who are members of the site. If set to true, only users who are members of the site can access the shared link.

    "updatePassword": This parameter determines whether to update the password associated with the link. If set to true, the password will be updated.

    "scope": This parameter specifies the scope of the link. The possible values are:

    0 - Anonymous access allowed

    1 - Internal users only

    2 - Existing external users only

    3 - New and existing external users

    Here is link for your reference:

    https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http

    I hope this helps you solve your problem!

     


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     

    Best Regards

    Cheng Feng