I need to download a file which is in SharePoint online programmatically. The link I have is in this format:


All the posts I can find refer to editing the URL from guestaccess.aspx to download.aspx, but that doesn't work for a URL in this format.

I'm trying to download the file in an AutoIT script, which will be available to a lot of users.

The link allows the file to be downloaded, but only by clicking the download button in Excel Online after the file is opened in a browser.

Is there any way I can do this? Amending the URL? Creating a different type of link in SharePoint? Or using any API?

  • Have you tried string path = "https://xxxxx.sharepoint.com/:f:/g/EkcBNxpXTKZJrg3xdBWlFBEBlgVj4FInALm_JVs4kYfK8w?e=tPfJVv"; string downloadUrl = siteURl + "/_layouts/download.aspx?SourceUrl=" + path; – Ankit Katiyar Nov 5 '18 at 5:04

Thanks for the response Lee_MSFT. I couldn't get your suggestion to work, but I got an answer on another forum.

I replaced everything after the last '?' with 'download=1'. Then the link can be used in my code to pull the file down.

Thanks for your help.

|improve this answer|||||
  • Worked for me yesterday – Lee Meador Nov 15 '19 at 15:40

When you request the anonymous link, user will be redirect to a URL with sourcedoc parameter, then you could download the file by download.aspx with UnqiueId parameter.



|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.