question

Krishna-9245 avatar image
0 Votes"
Krishna-9245 asked BakerKong-MSFT commented

Get Most Recent Documents from a Specific Sharepoint library

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

office-sharepoint-onlineoffice-sharepoint-server-development
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

BakerKong-MSFT avatar image
0 Votes"
BakerKong-MSFT answered BakerKong-MSFT commented

Hi @Krishna-9245,

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.


image.png (28.7 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your response. Do we have any official article which says we don't have such endpoint.

0 Votes 0 ·

No, both SP rest API/ASMX and MS graph do not have such endpoint. MS graph "List recent files" also targets to the site level, not a library. In fact they're from ms insight which is calculated using advanced analytics.

Thanks
Baker Kong


0 Votes 0 ·