How to export each file and folder URL via PowerShell or Graph API or MS Graph REST API from SharePoint Online? Is there any such way we can export from whole tenant and give it to users?

Mytoast Admin 290 Reputation points
2024-09-16T13:51:38.85+00:00

How to export each file and folder URL via PowerShell or Graph API or MS Graph REST API from SharePoint Online? Is there any such way we can export from whole tenant and give it to users?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,220 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rohit Raghuwanshi - MSFT 550 Reputation points Microsoft Vendor
    2024-09-17T06:25:21.37+00:00

    Hi Mytoast Admin,

    To export each file and folder URL from SharePoint Online, you can use the Microsoft Graph API. Specifically, you can use the following endpoint to get the webUrl for all the files and folders in a specific drive:

    GET https://graph.microsoft.com/v1.0/sites/{sitesId}/drives/{driveId}/root/children 
    

    This endpoint will return a list of items in the root of the drive, including their webUrl properties. You can iterate through these items to collect all the URLs. Additionally, you can call GET /sites endpoint to fetch all the sites in your tenant and iterate over them to collect URLs of all the files & folders.

    Make sure you have the necessary permissions (e.g., Sites.Read.All) and an access token to authenticate your requests.

    Please check the attached screenshot:

    User's image

    For more details, please refer https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.