Is there a possibility to retrieve a file by its document id url without knowing the list in which the file is stored?
I know I can do a
caml query on a list. But actually the file can be stored in several lists. For performance reasons, I don't want to loop through all lists.
I already tried to retrieve the document this way, but actually this does not work.
ClientContext = new ClientContext(SharePointUrl); ClientContext.Credentials = Credentials; docUrl = docUrl.GetRelativeUrl(docUrl); File file = ClientContext.Web.GetFileByServerRelativeUrl(docUrl); ListItem item = file.ListItemAllFields; ClientContext.Load(item, i => i.Id, i => i.File); ClientContext.ExecuteQuery();
The error is
Microsoft.SharePoint.Client.ServerException: 'The object specified does not belong to a list.'
with this relative url