I have a file in a Document Library. I can reach that file with a direct URL in the form https://[tenant].sharepoint.com/sites/[site_name]/[Document_Library]/[Sub_Folder]/document.pdf
Now what I'm trying to do is create a List View Command Set that will post the document to an API, something like: Request.addFileByUrl('....')
and pass the URL of the document as a parameter.
The problem is, I get a message "LinkKind cannot be Direct or Uninitialized". I've played around with some of the admin sharing settings to no avail. So my question is, is there a way to allow access to a direct URL temporarily or even somehow get the original document from the share link? Is there an option to integrate that method into a Command Set extension? (I am using the pnp/sp library at the moment to get the links)
Thank you for your help
Edit:
Here's the code that I am using to get the share link from my List View Command Set:
let getLink = await sp.web.getFileByServerRelativePath(filePath).getShareLink(SharingLinkKind.Direct, dateAdd(new Date(), "minute", 20));
let url: string = getLink.sharingLinkInfo.Url;
Now obviously the SharingLinkKind.Direct is the line that is giving me the error message, but I don't know how to work around it.
Request.addFileByUrl
?getShareLink(SharingLinkKind.Direct)
gets me the absolute url which you can extract from the second line of code I showed. However, in order to access the absolute url as an external user, or an API, there needs to be authorization. I'm looking to bypass this somehow so that the API can have access to the file contents