Getting SharePoint file content using Microsoft Garph API

vani baaz 26 Reputation points
2022-05-16T10:58:54.633+00:00

Is there a way to get sharepoint file content using Microsoft graph api? I know that we can get the download url from the graph API. But I need to get the file content without downloading.

Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} vote

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-05-16T11:44:22.797+00:00

    Hi @vani baaz ,

    Using driveitem-get-content, you get the content of the file.

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

    Please find response of my test.

    202280-850748-0.png

    Hope this helps.

    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 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. vani baaz 26 Reputation points
    2022-05-18T17:58:36.747+00:00

    Hi @SrinivasaRaoDarnaMSFT-7657, it worked for me. Thanks a lot.

    0 comments No comments

  2. Manav 0 Reputation points
    2024-02-19T07:41:31.4666667+00:00

    https://graph.microsoft.com/v1.0/sites/testingkhan.sharepoint.com,99c67d9f-5638-4fb9-9998-dd0ad4d204fa,744fa846-683b-4106-ba2a-6c592393710a/drive/items/1SOLVFJ2GKKNTAGGVMBCK2EC65TQKUR5J/content

    {
        "error": {
            "code": "invalidRequest",
            "message": "Invalid request",
            "innerError": {
                "date": "2024-02-19T07:39:40",
                "request-id": "ff25b2a2-224b-45a6-9aa7-71a4e1beac13",
                "client-request-id": "ff25b2a2-224b-45a6-9aa7-71a4e1beac13"
            }
        }
    }
    
    
    

    I am getting this error can anyone help?


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.