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

Cory Calavan 21 Reputation points
2021-09-09T21:35:39.013+00:00

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?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,521 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,655 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-09-10T01:58:47.983+00:00

    Hi @Cory Calavan ,

    You could use MS Graph Create a sharing link for a DriveItem to create an externally shareable URLfor a file: https://learn.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.

    0 comments No comments

  2. Cory Calavan 21 Reputation points
    2021-09-10T16:07:15.843+00:00

    @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?