要點是ParentUniqueId
屬性存儲父容器ID,在List Item
的情況下容器總是文件夾。
實施例1:
假設爲一個文檔庫的結構如下:
Documents (library)
|
Document.docx (document item with id = 1)
然後查詢:
/_api/Web/Lists/getByTitle('Documents')/items(1)/FieldValuesAsText?$select=ParentUniqueId
將返回的SP.List.rootFolder
值。
注:返回的值對應於Folder.UniqueId
和不到List.Id
下面的查詢演示瞭如何檢索文檔庫RootFolder.UniqueId
:
/_api/Web/Lists/getByTitle('Documents')/rootfolder/UniqueId
或
/_api/Web/GetFolderByServerRelativeUrl('Shared Documents')/UniqueId
實施例2
假設爲一個文檔庫的結構如下:
Documents (library)
|
Orders (folder)
|
Document.docx (document item with id = 2)
然後查詢:
/_api/Web/Lists/getByTitle('Documents')/items(2)/FieldValuesAsText?$select=ParentUniqueId
將返回Orders
文件夾的Folder.UniqueId
值。
相應的查詢檢索Orders
文件夾UniqueId
屬性:
/_api/Web/GetFolderByServerRelativeUrl('Shared Documents/Orders')/UniqueId
謝謝!在我的情況下,URL是>>> _api/Web/GetFolderByServerRelativeUrl('Documents')/ UniqueId – 2014-09-29 05:21:21