Hi,
I am trying to use CSOM to fetch the list item version history programmatically.
I have used the below code:
//Below code is run on Custom List
public static void GetAllFileVersions(string fileUrl)
{
ClientContext context = new ClientContext(siteUrl);
Microsoft.SharePoint.Client.File file = context.Web.GetFileByServerRelativeUrl(fileUrl);
FileVersionCollection versions = file.Versions;
context.Load(versions);
context.ExecuteQuery();
if (versions != null)
{
foreach (FileVersion _version in versions)
{
Console.WriteLine("Version : {0}", _version.VersionLabel);
}
}
}The fileurl parameter is having the value as :
//ID contains the item Id string fileUrl = ""; fileUrl = "/Lists/" + listName + "/" + ID + "_.000";
I am getting the error as "Value does not fall within the expected range." in the ExecuteQuery line.
versioning is enabled on the list.
How to fix this?
Thanks