Getting a List of Files from a Sharepoint Shared Link

Written by James McDonald

January 27, 2022

So recently I had a customer ask if they can be notified when the files change in a Microsoft Teams Sharepoint URL which was shared with Contribute permissions with sign-in NOT required.

The link provided did not allow the person to choose “Sync” and then mirror the folder structure in their Own OneDrive
And there doesn’t appear to be a way to set up alerts because you can’t alert “anonymous”.


An example of the link provided is the following:
https://example.sharepoint.com/:f:/s/mytestteamsite/EhWIF7ehmopLosy9HzbJotQBom1_rk9goDptDd-VOVHcxg

When you click on a sharepoint Shared Link URL similar to the above ( While not authenticated ) it will redirect you to the “proper” URL similar to the following and allow you to access the files.

https://example.sharepoint.com/sites/mytestteamsite/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2Fmytestteamsite%2FShared%20Documents%2FTestSharedFolder&p=true

Once you have the above URL you can get the list of files in XML format by editing the URL to include this snippet _api/web/lists/getbytitle(‘Documents’)/items?

https://example.sharepoint.com/sites/mytestteamsite/_api/web/lists/getbytitle(‘Documents’)/items?$select=FileLeafRef,FileRef&id=%2Fsites%2Fmytestteamsite%2FShared%20Documents%2FTestSharedFolder&p=true

Requesting the above URL will return an XML list of filename (FileLeafRef) and filepath (FileRef) which you can then compare programmatically with previous output and alert people via email when a change happens.



0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...

Ubuntu on Hyper-v

It boils town to installing linux-azure # as root or sudo apt-get update apt-get install linux-azure...