Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Error: Value does not fall within the expected range. -Fetching list item version history

$
0
0

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




Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>