Get Most Recent Documents from a Specific Sharepoint library

Krishna Sandeep Sangani 61 Reputation points
2020-11-10T21:06:21.703+00:00

Hi Team,

Hope everyone is doing well.

I am working on develop a script to get most recent document from a SharePoint Online library.

I can get documents based on modified date and modified by user column filters to present My recent documents of each user.

But now, Is there any way to get documents if someone opens and just view/read. So that I can show recent documents even any user access the document. Could you please share any rest api to get docs.

Appreciated in advance.

Thanks

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,562 questions
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,604 questions
0 comments No comments
{count} votes

Accepted answer
  1. Baker Kong-MSFT 3,801 Reputation points
    2020-11-11T07:13:52.863+00:00

    Hi @Krishna Sandeep Sangani ,

    I believe there is no such endpoint to get the most recent documents from a specific Sharepoint library. Site usage and Recent documents web part could display the most recent documents accessed by the current user of the page.

    • Site usage

    38975-image.png

    By means of F12 tool, we can find the Request url :

    https://abc.sharepoint.com/_api/v2.1/sites/abc.sharepoint.com,5ae427d1-c859-4c58-97c4-e20ad27b850b,352d1542-3d0a-4f99-a529-723e41552082/items?$filter=isof('oneDrive.Item') AND oneDrive.item/file ne null&$expand=analytics($expand=lastSevenDays)&$orderby=analytics/lastSevenDays/access/actorCount desc  
    

    However all the above cannot scope into a specific Sharepoint library, their target is the site.

    Best Regards,
    Baker Kong


    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.


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.