About Microsoft Graph API Get OneDrive Word File Content

Gamze 26 Reputation points
2022-04-28T10:30:45.84+00:00

Hi guys,

I am using Microsoft Graph Api for create, upload and download docx/doc document on OneDrive. But I want to reach only content inside the uploaded document or existing document in OneDrive. I tried the get item and download services with Postman, Graph Explorer website and java code. But the servces didn't return the only content. Could you help me about this?
if anyone has tried it before.

(The response result can be base64 or even binary, enough to return :) )

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

Accepted answer
  1. Shivam Dhiman 5,946 Reputation points
    2022-04-28T11:45:56.447+00:00

    Hi @Gamze

    To get the content of your word file, locate that file in OneDrive using this endpoint.

    GET /me/drives/{drive-id}/root/children  
    

    Now get the items-id(word file id) from the response and put it in below endpoint in Postman to get the content of your word file.

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

    Note: Response for this API https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/content does not come in Graph Explorer due to CORS policy. Please use Postman(API client) to execute this request

    You can refer to this documentation for more details

    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".


0 additional answers

Sort by: Most helpful