GetFile with Id instead of Relative Url in Rest API

developer sp1 461 Reputation points
2020-09-22T01:42:25.54+00:00

I know we can get file by relative url like this:

/_api/web/getFileByServerRelativeUrl('/sites/Test/Documents/Doc1.docx')

But now I want to get with Id like this:

/_api/web/GetFileById('<file unique id>')

I don't know how to get this file unique id can anyone help me please ?

Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

Accepted answer
  1. ZhengyuGuo 10,586 Reputation points Moderator
    2020-09-22T07:44:06.93+00:00

    Hi @developer sp1 ,

    You can get the file guid using rest api like this:

    /_api/web/lists/getbytitle('Documents')/Items/GetById(44)/file

    26387-snipaste-2020-09-22-15-41-08.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.