web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to set password in...
Power Automate
Unanswered

How to set password in 'Create sharing link for a file or folder' in Sharepoint action

(1) ShareShare
ReportReport
Posted on by

I want to share folder to anyone with password like what I can do in Sharepoint manually.

I only find 'Link Expiration' in 'advanced options'.

Categories:
I have the same question (0)
  • Verified answer
    v-bacao-msft Profile Picture
    on at

     

    Hi @Anonymous ,

     

    Unfortunately, Create sharing link for a file or folder action does not support setting password currently. I am afraid that there is no suitable way to achieve your needs.

     

    If you want a similar feature to be supported by MS Flow, please consider submitting your suggestion on the ideas forum so it might be considered for future releases.

    https://powerusers.microsoft.com/t5/Power-Automate-Ideas/idb-p/FlowIdeas

     

    Best Regards,

  • djje87 Profile Picture
    14 on at

    I appreciate this question was asked nearly two and a half years ago - but it came up in a Google search when I was looking to do the same thing.

     

    Although the in-built "Create sharing link for a file or folder" SharePoint action still doesn't support adding a password to "Anyone" links, you can instead create such a link (and more!) using the "Send an HTTP request to SharePoint" action. This essentially opens up the wider SharePoint API to be consumed in the Power Platform.

     

    Here's the endpoint/URL to POST to

    _api/web/Lists('YourLibraryGUID')/GetItemById('YourItemID')/ShareLink

     

    Here's the request body

    {

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

     

    Use your browser's developer tools to see what requests the browser sends when you click the UI in SharePoint - from there you can figure out the API (as well as Googling it!).

  • Community Power Platform Member Profile Picture
    on at

    Hello, when I try this it gives me "Bad request" and keeps going forever. I have used the exact request body as above. Any suggestions?

  • djje87 Profile Picture
    14 on at

    Hi - here's a screenshot of the "Send an HTTP request to SharePoint" action.


    Looks like I didn't mention any Header values in my original post - not sure if they're required to work, but won't harm to include them (key: accept, value: application/json;odata=verbose).

    djje87_0-1675811575394.png

    As in my original post, the first parameter in the Uri is the GUID of the document library, the second is the ID of the file or folder you want to create the link for. So you'll have something that looks like this for the Uri:

    _api/web/Lists('4655c07a-2dd2-493c-8fe9-4bc203d865ec')/GetItemById('420')/ShareLink

  • johnjohn123 Profile Picture
    3,506 on at

    @djje87 

     

    thanks for the code you posted, but from where we can get more info about the parameters that we can pass inside the body:-

     

     

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

     

  • djje87 Profile Picture
    14 on at

    Hi John - sorry, I've only just seen your question.

    You'd think it would be covered somewhere in MS's API docs, but I can't find it. I used the Network section of my browser's developer tools to see the request when creating the links via the SharePoint UI. A bit of trial and error from there should allow you to figure out the less obvious properties.

  • johnjohn123 Profile Picture
    3,506 on at

    @djje87 i were not able to find any documentation regarding the "ShareLink" end point.. so i am not sure if we can rely on the browser developer tool to inspect the parameters... i mean those parameters might get changed in the future ? am i correct? also i found those 2 links regarding some of the parameters:-

     

     

    and there is a warning that those are subject to change.. what do you think?

  • djje87 Profile Picture
    14 on at

    Those two links are great - they inform what some of the number values mean.

    You're right - things could change in the future - but the same is true whether you're using the API based on what you can learn from inspecting the dev tools or from the docs. If there aren't any docs for this specific end-point then perhaps Microsoft won't announce any changes they make - you'd just have to rely on users shouting up if/when things break!

  • johnjohn123 Profile Picture
    3,506 on at

    @djje87 the problem is that we are planning to use those actions in a scheduled flow,, to do some checking and create sharing links to the external users so they can only view the documents.. so we do not want the flow (in the future) to start granting edit permissions instead of just read or start sending invitations to wrong users.. since we are relying on inspecting the browser network tab instead on an official documentation.. this is my point.

  • djje87 Profile Picture
    14 on at

    This thread is about creating an anonymous sharing link with a password. The standard "Create sharing link for a file or folder" action in Power Automate doesn't accommodate the "with a password" bit. If your use case doesn't require a password, you'd be better off using the standard action (for future robustness).

    Neither the standard action, nor my workaround using the "Send an HTTP request to SharePoint" action send the link to anyone (it just creates the link and returns it to the flow) - so there's no risk of sending to the wrong person (at this part of the flow at least!).

    I've found this - [MS-CSOMSPT]: Microsoft.SharePoint.Client.Sharing.ShareLinkRequest | Microsoft Learn (via this sharepoint online - SPONLINE - How to generate a sharing link via REST? - SharePoint Stack Exchange). If you expand the tree on the left-hand side, you'll see the different properties. Not sure if these are placeholder pages by Microsoft, as there's not much written in them (!) - but it might give you some comfort around using this "undocumented API".

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard