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 ?

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,576 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful