Reputation: 158
I have a requirement to grab a file from a SharePoint site and attach it to an email. The end user provides the URL to the file, and power automate handles the rest. Originally I was working with a specific "style" of URL and I was able to correctly parse the URL to get the file content.
However, I am not able to figure out how to use Power Automate with a different url, Style B.
Style A is created using the "Share" or "Copy Link" command within sharepoint. Style B is created when you open an editable file and simply copy the URL from the address bar (which I'm finding is how most end users intuitively grab the link).
With Style A, I can parse the folder structure from the URL directly. This is left out of Style B, so I can't configure any of the Power Automate SharePoint integrations to work correctly. "sourcedoc" is a GUID and I thought I could make some use of that, but apparently that is not the File ID that Power Automate needs to work.
I'm open to any options, including custom REST scripts if I need to be.
Upvotes: 0
Views: 3954
Reputation: 1497
You could use the Guid/UniqueId from Style B in a GetFileById method within a Send an HTTP request to SharePoint action. That response should give you details like ServerRelativeUrl property value.
You can use that value in a Get file Content using path (with a slice function expression)
Below is an example
1.Uri for the Send an HTTP request to SharePoint action
_api/web/GetFileById('@{variables('UniqueId')}')
2.Expression which you can use in the File Path field of the Get File Content Using Path action. Uses slice and nthIndexOf functions
slice(outputs('Send_an_HTTP_request_to_SharePoint')?['body']['ServerRelativeUrl'], nthindexOf(outputs('Send_an_HTTP_request_to_SharePoint')?['body']['ServerRelativeUrl'], '/', 3))
Upvotes: 1