how to preveiew the sharepoint file using REST API

Akram Baig Mirza Mohamad 0 Reputation points
2023-09-25T13:19:21.4266667+00:00

We want to display the sharepoint file into salesforce. is there any Rest api to get the file into external system. If yes what will be the REST API, if no then what will be the approach to display/Preview file.

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-09-26T02:37:29.12+00:00

    Hi @Akram Baig Mirza Mohamad,

    Per my test, you can use the following rest api to get the content of a file. But this api can only get the files in Shared Document.

    http://mysite.sharepoint.com/<site_name>/_api/web/getfilebyserverrelativeurl('<url>)/$value?binaryStringResponseBody=true
    

    For the files in other library I will recommend you to use graph api driveitem-get-content

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

    202280-850748-0.png


    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

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.