How can I get the UniqueId for a List?(say Documents list)
For a root level item(meaning this item is at the first level of Documents list) when I get its ParentUniqueId, it gives me the UniqueId of the list it lies under. Now my problem is that I'm unable to get the UniqueId for a list(when I get the meta for it) so that I can differentiate that this ParentUniqueId is either my list's UniqueId(which in this case is Documents list) or the UniqueId for another item which this item lies under(file within a folder or folder within a folder).
Much appreciated!
The point is that ParentUniqueId
property stores the parent container id, in case of List Item
the container is always Folder.
Example 1:
Assume the following structure for a Documents library:
Documents (library)
|
Document.docx (document item with id = 1)
Then the query:
/_api/Web/Lists/getByTitle('Documents')/items(1)/FieldValuesAsText?$select=ParentUniqueId
will return the value of SP.List.rootFolder
.
Note: the returned value corresponds to
Folder.UniqueId
and not toList.Id
The following queries demonstrate how to retrieve Documents library RootFolder.UniqueId
:
/_api/Web/Lists/getByTitle('Documents')/rootfolder/UniqueId
or
/_api/Web/GetFolderByServerRelativeUrl('Shared Documents')/UniqueId
Example 2
Assume the following structure for a Documents library:
Documents (library)
|
Orders (folder)
|
Document.docx (document item with id = 2)
Then the query:
/_api/Web/Lists/getByTitle('Documents')/items(2)/FieldValuesAsText?$select=ParentUniqueId
will return the Folder.UniqueId
value of Orders
folder.
The corresponding query to retrieve Orders
folder UniqueId
property:
/_api/Web/GetFolderByServerRelativeUrl('Shared Documents/Orders')/UniqueId
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments