cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bee-Xpert
Frequent Visitor

Get an existing sharing link from an item or folder in SharePoint with PowerAutomate

Hello,

 

I've created a flow which allow me to automate this process :

1) Create a "customer folder" in my SharePoint library

2) Sharing it to an external user with the block "Grant access to an item or a folder"

 

Then I would like to

3) Get the new "Sharing Link" from my Flow (manually accessible on right-click & "manage access" from the item on my SharePoint)

5) Save user e-mail & this "Sharing Link" to an Excel database

4) Send a custom e-mail (not the automatic one built on the block) with the new "Sharing Link"

 

But How to GET this new "Sharing Link" on my Flow after it has been created from the block "Grant access to an item or a folder".

 

I tried something like @{outputs('Grant_access_to_an_item_or_a_folder')?['body/link/webUrl']} but it's not working.

Maybe the solution is an HTTP request ?

 

Thanks,

 

Dylan Bergozza

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MarvinBangert
Super User
Super User

Hi @bee-Xpert 

there is a way to get this information using a SharePoint action "Send an HTTP request to SharePoint":

Site Address: <Select your Site>

Method: "POST" (GET is not supported)

Uri: "/_api/web/lists/getbytitle('<Your Library Name>')/items(<Your Item ID>)/GetSharingInformation?$select=permissionsInformation&$Expand=permissionsInformation"

Headers:

AcceptApplication/json
Content-TypeApplication/json

 

This will give you an overview about the different permissions giving from that SharePoint item. Within "permissionsInformation"/"Links"/"linkDetails"/"Url" you will find the Url you generated from the action before.

 

You will find the invited user in "Invitations", to send a custom email, deactivate the "Notify recipients" within the "Grant access to an item or a folder" and just send an email using the "Office 365 Outlook" connector.

 

Does this help you? Otherwise please give me some more information.

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

Blog: Cloudkumpel

View solution in original post

9 REPLIES 9
MarvinBangert
Super User
Super User

Hi @bee-Xpert 

there is a way to get this information using a SharePoint action "Send an HTTP request to SharePoint":

Site Address: <Select your Site>

Method: "POST" (GET is not supported)

Uri: "/_api/web/lists/getbytitle('<Your Library Name>')/items(<Your Item ID>)/GetSharingInformation?$select=permissionsInformation&$Expand=permissionsInformation"

Headers:

AcceptApplication/json
Content-TypeApplication/json

 

This will give you an overview about the different permissions giving from that SharePoint item. Within "permissionsInformation"/"Links"/"linkDetails"/"Url" you will find the Url you generated from the action before.

 

You will find the invited user in "Invitations", to send a custom email, deactivate the "Notify recipients" within the "Grant access to an item or a folder" and just send an email using the "Office 365 Outlook" connector.

 

Does this help you? Otherwise please give me some more information.

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

Blog: Cloudkumpel

bee-Xpert
Frequent Visitor

Hi @MarvinBangert,

 

Thanks a lot ! That works perfectly.

 

The hardest thing was to Parse my JSON correctly because I got this error :

"Invalid type.  Expected String but not Null"

 

Adding "null" type to the JSON shema resolved this issue.

 

Now everything is perfect 👍

 

Thanks again.

Thank you @MarvinBangert -- you are a lifesaver!

AlexGran
Regular Visitor

Hi @MarvinBangert 

I'm kind of a rooky in Power Automate 😅

How can I get the URL from the body with json to put it in a mail ?

tgraham
Frequent Visitor

Hi @AlexGran , here's how I did it after reading other forums. After the HTTP Request, drill-down to information you want first, then Parse JSON. In the schema of the Parse JSON action, replace each "type": [ "string" ] with "type": [ "string", "null" ] then you'll be able to get what you need from the dynamic content picker.

 

tgraham_0-1664548161943.png

tgraham_1-1664548265791.png

 

 

Thanks @tgraham for your help but I don't have "Get sharing information" in my list 😭

bee-Xpert
Frequent Visitor

Hi @AlexGran ,

You misunderstood tgraham screenshots. The first block is a "Send an HTTP request to SharePoint" block renamed in "Get sharing information". 

 

a.jpg

 

To get a Sharing URL from a SharePoint element after the HTTP request, you need to "Parse JSON" from returned "body".

For this you need a Parse JSON Schema. Here you have a description to get one from your flow answer : Where to get Schema for the Parse JSON action in Power Automate.

Here is the simplified schema I made you can use to get only the url :

 

 

 

{
    "type": "object",
    "properties": {
        "permissionsInformation": {
            "type": "object",
            "properties": {
                "links": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "linkDetails": {
                                "type": "object",
                                "properties": {
                                    "Url": {
                                        "type": [
                                            "string",
                                            "null"
                                        ]
                                    }
                                }
                            }
                        },
                        "required": [
                            "linkDetails"
                        ]
                    }
                }
            }
        }
    }
}

 

 

 

 

b.jpg

 

Then, because there is many links for each element in SharePoint, you need to filter the links to get only those with a non-null URL. So use "Apply to each" on links from the previous Parse JSON, check if the URL is not null and send an e-mail.

 

c.jpg

 

And that's it, you will receive all Sharing links on the element one by one. I hope this is what you needed !

 

Regards,

Dylan

Merci beaucoup Dylan,

 

Thanks for your help!

But with the schema that you published I'm not able to select the URL in the condition part. The URL is missing in the list.

 

Bien à toi,

Alex

 

 

@bee-Xpert , I followed your steps, but I can't find 'Url' in dynamic content in the e-mail corps step. Do you know why?

 

gui_levcovitz_0-1666198989430.png

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (3,444)