0

Using SharePoint REST API, i can do the following POST request to create an anonymous sharing link with password:-

1- Method:- POST

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

3- Body:-

{

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

this mimic this UI action for creating anonymous sharing link-

enter image description here

but how i can modify the Body parameters to create a link for specific users instead, which can be achieved from the UI using this action: -

enter image description here

any advice please?

1 Answer 1

2

You you provide lists of users using peoplePickerInput property as shown in below:

{

"request":{
    "createLink":true,
    "peoplePickerInput":[ { "Key":"[email protected]", "IsResolved":false },{ "Key":"[email protected]", "IsResolved":false } ]
    "settings":{
        "allowAnonymousAccess":true,
        "linkKind":6,
        "role":1,
        "restrictShareMembership":false,
        "updatePassword":true,
        "password":"***",
        "scope":0
    }
}

}

Please go through with below sample solution which I prepared in C# for same purpose. Here you can check what possible input we can provide for different scenario.

Share Document with REST API - c#

Similar Thread:

SPONLINE - How to generate a sharing link via REST?

8
  • ,, but you are passing 2 paramters that contradicts with each other ` "linkKind":6, "role":1,` am i correct? .. as linkkind=6 allow anonymousEdit while role=1 grant read-ony?? am i missing something? May 12, 2023 at 11:45
  • also i do not want to create anonymous links, i want to create a link shared with specific users,, so i should pass ` "allowAnonymousAccess":false,instead of "allowAnonymousAccess":true,`? May 12, 2023 at 11:47
  • I have just provided my input how you can pass users as an sample May 12, 2023 at 12:02
  • but i do not want to create anonymous links, i want to create a link shared with specific users,, so i should pass ` "allowAnonymousAccess":false,instead of "allowAnonymousAccess":true,`? – May 12, 2023 at 13:49
  • but i do not want to create anonymous links, i want to create a link shared with specific users,, so i should pass "allowAnonymousAccess":false, instead of "allowAnonymousAccess":true,? May 12, 2023 at 14:25

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.