Read the content of a Sharepoint file using the API

George Xydias 5 Reputation points
2024-04-09T08:17:04.0566667+00:00

Hello team,

I want to build an integration with Sharepoint platform and use the API you provide.

The goal is to fetch the content of every document in a site

Therefore I created an app in order to use it for OAuth2

The application has the following permissions:

  • AllSites.Read
  • AllSites.Write

Steps i did so far:

I am trying to fetch all sites using the following url

After I fetch the site id I wanted to fetch the drives so I used

And then I use the drive id to fetch all the items in the drive:

I also did this:

During the implementation I also tried to fetch the content of each document in the list of the xxxxx.sharepoint.com site.

(list id and item id in the following url are valid)

The above returns a binary response and I cannot read the actual content of the document.

I tried to decode the content using iso-8859-1 and utf-8, but I did not manage to read the content of the file.

Is there any endpoint I can use in order to read the content of a file?

Thanks in advance

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,673 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,376 Reputation points Microsoft Vendor
    2024-04-10T06:57:45.82+00:00

    Hi @George Xydias,

    If you want to connect sharepoint with rest api, I would recommend you to use SharePoint app only. You could refer to following steps in the article

    https://billyperalta.com/Accessing%20SharePoint%20REST%20API%20using%20Postman/


    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.