Hi @john john ,
Do you want to simulate the UI interface, send file sharing links to external people through flow, and only have read-only permissions?
Here is a test for your reference:
Create a file in the folder:
__
First, Create a flow and set manual triggers:
Second,you need to obtain an access token to authenticate your request. You can do this by using the "Send an HTTP request to SharePoint" action with the following configuration:
Method: POST
Uri: _api/contextinfo
Headers: Accept: application/json;odata=nometadata
Next, you can use the following API endpoint to create a sharing link with read-only permission for external users:
Method: POST
Uri: _[api/web/lists('your]/GetItemByID('youritemid')/sharelink
Headers:
Accept: application/json;odata=nometadata
Content-Type: application/json;odata=nometadata
X-RequestDigest: [YourAccessToken]
(In power automate, we can use the formula to get the fields we need in the returned content)
Here is the body of a request to create a shared link, where:
{
"request":{
"createLink":true,
"settings":{
"allowAnonymousAccess":true,
"linkKind":3,
"role":0,
"restrictShareMembership":false,
"scope":0
},
}
}
createLink :specifies whether to create a shared link, here set to true means to create.
allowAnonymousAccess :specifies whether to allow anonymous access, here set to true means to allow.
linkKind : Specifies the type of shared link, here setting it to 3 means generating a link that can be sent by email.
role :specifies the role of the shared link, here it is set to 0 for read-only permission.
restrictShareMembership : specifies whether to restrict the members of the shared link, here set to false means no restriction.
scope :specifies the scope of the shared link, here setting it to 0 means the link is visible to everyone.
Finally, Send the email.
Please use the formula to dynamically obtain the sharelink in the content returned by the above request
Sharelink: body('Send_an_HTTP_request_to_SharePoint_2')?['sharingLinkInfo/Url']
Send emails in the form of <a>, and you can also customize the content of the email
Here is result:
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