Downloading file from sharepoint site folder using Graph

-- -- 957 Reputation points
2021-10-23T10:32:01.45+00:00

Hi

How can I download a document from a SharePoint site folder via MS Graph? Fluent api if possible.

Thanks

Regards

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,719 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.
3,696 questions
0 comments No comments
{count} vote

Accepted answer
  1. Shivam Dhiman 6,081 Reputation points
    2022-02-10T19:23:12.763+00:00

    HI @-- -- ,

    To get content of file please follow below steps

    Step 1: To get drive id use this graph API endpoint https://graph.microsoft.com/v1.0/me/drives
    173274-drive.png

    Step 2: To get the drive items use this Graph API endpoint, https://graph.microsoft.com/v1.0/me/drives/{drive-id}/root/children Put the drive ID which captured from step 1.
    173285-drivechildren.png

    Step3: To get the files present in that folder use this Graph API endpoint, https://graph.microsoft.com/v1.0/me/drives/{drive-id}/items/{item-id}/children Put the ID(Folder ID) captured from step 2
    173227-getfile.png

    Step4: To get the file content use this Graph API endpoint, https://graph.microsoft.com/v1.0/me/drives/{drive-id}/items/{item-id}/children Put the file id in item id which captured in step 3
    173178-downloadcontent.png

    Refer this document for more details

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


1 additional answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,126 Reputation points
    2021-11-02T07:27:09.233+00:00

    Hi @-- -- ,

    You could use this endpoint to download the file in sharepoint:

    GET /drives/{drive-id}/items/{item-id}/content  
    

    Please refer to the documentation: https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.



Your answer