Get Files in One Drive Folder Sorted By Updated Time

依然范特西╮ 提交于 2020-01-17 04:22:30

问题


I have an apps that allow user to pick an apps backups from specific folder in One Drive.

I want to show only 10 files from this folder sorted by file Updated Time (DESC), I have found how to limit the files by appending limit=10 to query path.

I'm using Live SDK ver 5.6.1 package from Nuget.

LiveConnectClient client = new LiveConnectClient(session);
var result = await client.GetAsync(string.Format("{0}/files?limit=10", folderId));

But cannot find how to sorted by Updated Time.


回答1:


I'm not sure we are using the same version of the REST API, but the one documented at http://onedrive.github.io/index.htm (using dollar notation for the parameters) uses $orderby . For example,

https://api.onedrive.com/v1.0/drive/items/[FOLDER ID]/children?$orderby=lastModifiedDateTime%20desc

However, if you are stuck on the older Live SDK, according to the documentation at https://msdn.microsoft.com/en-us/library/hh826531.aspx you should be able to use

FOLDER_ID/files?sort_by=updated&sort_order=descending

That's exactly what Clint suggested, so if that doesn't work for you, you might want to consider updating to the newer API. I can confirm that sorting definitely works there.




回答2:


I haven't tried this but...

var result = await client.GetAsync(string.Format("{0}/files?limit=10&sort_by=updated", folderId));


来源:https://stackoverflow.com/questions/29485895/get-files-in-one-drive-folder-sorted-by-updated-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!