REST API Error:: Querying ParentUniqueId for a list item
-
29-09-2020 - |
Question
I'm looking for a way to retrieve the parent Id for a list item so that I can query it as well.
For a given list item say id 101, I need to find the Id for its parent (the folder it lies under or the list if it's at the root, i.e, Document list Id)
Is this possible? I have been trying to get ParentUniqueId for a list item but its giving me the following error.
{
"error": {
"code": "-1, Microsoft.SharePoint.SPException",
"message": {
"lang": "en-US",
"value": "The field or property 'ParentUniqueId' does not exist."
}
}
}
The call I am making is;
- https://{sitecollection}/{personal_site}/_api/Web/Lists(guid'blabla')/Items(blabla)?$select=ParentUniqueId
Is there any other way to get this information?
Solution
Unfortunately ListItem resource in SharePoint 2013 REST interface does not expose ParentUniqueId
property.
But you could use the following query to return ParentUniqueId
property for ListItem
:
/_api/Web/Lists/getByTitle('<list title>')/items(<item id>)/FieldValuesAsText?$select=ParentUniqueId