Monday, October 6, 2014

Get a list of the current user’s recent documents

When navigating to OneDrive in SharePoint Online you get a nice list on the left showing your recent documents. The list show documents you have recently used, that being opened/viewed or stored. I suspect this is sort of overlapping with My work in Delve, but different API’s and results.

image

A recent discussion internally about bringing relevant content to you on your start page, made me dig into this. Put it as part of your intranet home page, or filter the site on any project site, to show your most recent files. It’s all about you!

So, how do you get this list of documents? By using a REST call to the end-point

https://<tenant>.sharepoint.com/_api/me/getrecentdocs

If you add the usual headers of application/json;odata=verbose, you get the data back as JSON. If not, you get it as XML. For me it returned 31 items, more than enough for a good listing.