Shorter share link format in OneDrive and SharePoint
Links to shared files and folders in OneDrive and SharePoint are now shorter and have a new format. For example, the following shows the old and new format for a OneDrive link that works for anyone inside the organization.
Links that were shared before this change was introduced are not affected by the change and will continue to work.
The new link format might affect applications or services that inspect or take dependencies on OneDrive or SharePoint URL structures, especially if those applications or services parse the site URL or specific strings. The new short links are compatible with all APIs that work with
The following are some scenarios that are affected by this change:
Applications that parse a URL input by an end user to get the site URL in order to construct SharePoint REST API requests such as GetFileByUrl or GetSharingLinkData.
Applications that take URL input from an end user and use CSOM to attempt to query file information.
Applications that parse a URL input by an end user to determine whether it is an anonymous or an internal-only sharing link.
Apps that use Microsoft Graph to interact with SharePoint links will continue to work. For more information, see Accessing shared DriveItems.
SharePoint REST API
The SharePoint REST API does not have a supported way to interact with user input links. We recommend that you migrate to the Microsoft Graph shares API if possible.
If you’re unable to migrate to Microsoft Graph, you can use the following workaround. Note that this workaround is not supported.
Determine the base URL. This is now the hostname of the link.
Construct the API request by concatenating the base URL,
SP.RemoteWeb, and a specific API method, as shown.
For example, for the following input URL:
This is the original API request:
This is the new API request:
To determine the specific type of link, inspect the
IsAnonymous fields in the response for the GetSharingLinkData API (replace GetFileByUrl with GetSharingLinkData in the examples). Use this method instead of parsing URLs for tokens such as
CSOM does not have a supported way to interact with user input links. Some applications open a ClientContext and query the file metadata by successively truncating path segments from the SharePoint link until the ClientContext constructor succeeds. This approach no longer works with the new URL format.
To work around this:
Open a ClientContext on the root site (scheme://hostname).
Web.WebUrlFromPageUrlDirect()to get the web URL of the link.
Open a new ClientContext using this web URL to make additional requests.
This approach is not supported.
Send feedback about: