question

CoryCalavan-8908 avatar image
0 Votes"
CoryCalavan-8908 asked MichaelHan-MSFT commented

Best way to generate shareable URL from on prem Windows application's generated file

Hey All,

I am a systems guy who recently migrated to O365/Azure infrastructure. I have a team that develops a .NET Windows application and am trying to figure out the best path for creating an externally shareable URL from a file generated by the app. The app is used by customers which during a process generates a PDF and need to call an API to pass the downloadable URL for that PDF. I poked around graph and the documentation is really difficult to find a clear path to accomplish this and keep running into access denied issues even when I use my global admin account. I need to stay away from any user authentication and don't really need historical record of the files persisted, just to create a URL that can be shared to the next API call.

Any suggestions?

sharepoint-devmicrosoft-graph-sdk
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered MichaelHan-MSFT edited

Hi @CoryCalavan-8908,

You could use MS Graph Create a sharing link for a DriveItem to create an externally shareable URLfor a file: https://docs.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http

For example POST /sites/{siteId}/drive/items/{itemId}/createLink


If an Answer is helpful, please click "Accept Answer" and upvote it.
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CoryCalavan-8908 avatar image
0 Votes"
CoryCalavan-8908 answered MichaelHan-MSFT commented

@MichaelHan-MSFT

Thanks for the reply. I figured this would be the end result but I'm struggling getting the application auth to work for writing the file to sharepoint. I assume that is the first step right? Persist the file to SharePoint then use this to generate the shareable link? I think the issue is up until now we've used a token that is delegated and tied to a user. For this i'm trying to use an Application token and I am having issues getting that into the code and authenticated - keep getting Access Denied for the write. I can get info on the SP site but can't write the file. I tried throwing every SP/MS Graph permission to it as I could. Any suggestions?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@CoryCalavan-8908,

How do you write the file to SharePoint? Use SharePoint CSOM or MS Graph api? You could share the code so I could help you more.

0 Votes 0 ·