Sharepoint Get File by Id

Harsha Vardhini 25 Reputation points
2023-10-11T12:54:00.7333333+00:00

I have used the api __https://{tenant}-.sharepoint.com/sites/TestSite/_api/web/GetFileById('<unique-file-id>') __to get the details of a file using the siteName and the unique file id

This works for Sharepoint Online. Will this work for all sharepoint on-prem and online accounts. And if possible could I get the official documentation for this api.

Thanks in Advance

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,900 questions
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 33,641 Reputation points Microsoft Vendor
    2023-10-12T03:13:44.8366667+00:00

    Hi @Harsha Vardhini,

    The api should contain list name or list id. You can refer to following api

    GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items({item_id})
    Authorization: "Bearer " + accessToken
    Accept: "application/json;odata=verbose"
    

    Here is the document for reference

    https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-rest


    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful