Are there Graph APIs for Uploading/Downloading Documents to/from Sharepoint site

Patil, Vinod V 40 Reputation points
2023-01-27T21:50:55.48+00:00

Do we have Microsoft graph APIs to upload and download documents to and from Sharepoint folders? Please provide those and any link to get details.

Thanks.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,506 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,946 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shivam Dhiman 6,066 Reputation points
    2023-01-27T22:49:18.0566667+00:00

    Hi @Patil, Vinod V

    To upload file in SharePoint folder, use this Graph API endpoint.

    PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content

    Please refer to this documentation for more details.
    To upload bigger file please follow this documentation.

    To download file from SharePoint, use this Graph API endpoint.
    GET /sites/{siteId}/drive/root/children

    The above endpoint will give you all files in your sites drive. Use the id of the file which you want to download.

    GET /sites/{siteId}/drive/items/{item-id}

    The above endpoint will give you download URL which you can use to download that file.
    Also, you can use GET /sites/{siteId}/drive/items/{item-id}/content endpoint to get the raw content of file.
    Please refer to this documentation for more details

    Hope this helps.

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


1 additional answer

Sort by: Most helpful
  1. Patil, Vinod V 40 Reputation points
    2023-02-02T21:35:01.21+00:00

    Thanks Dhiman, Tong.

    I am able to upload a file to sharepoint using PUT but it doesn't show the file in the folder on sharepoint. When I use POST using COPY uri and create another copy of the file, it shows that copy in the folder but not the original created. What could be the issue?

    Thanks.

    0 comments No comments

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.