如何下载列表项版本

How can I download the list item versions

我的问题是关于在线共享点。 在我的项目中,我想下载列表项及其版本。我可以下载当前列表项版本,但无法下载其版本。我参考了 this answer,其中显示了如何计算规范路径和修订路径。但是在获取数据时出现错误

远程服务器返回错误:(403) 禁止访问。

并作为响应 header 获得价值 "Access denied. Before opening files in this location%2c you must first browse to the web site and select the option to login automatically."

 string url = "https://test.sharepoint.com/teams/Mycompany";
ScureString f_SecurePass = new SecureString();
foreach (char ch in password)
    f_SecurePass.AppendChar(ch);

clientcontext = new ClientContext(url);
var credentials = new SharePointOnlineCredentials(userid, f_SecurePass);                
clientcontext.Credentials = credentials;
Web web = clientcontext.Web;
clientcontext.Load(web, website => website.Lists);
clientcontext.ExecuteQuery();

CamlQuery camlQ = new CamlQuery();                            
camlQ.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
                    "<Value Type='Number'>0</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";

var cq = _list.GetItems(camlQ);
clientcontext.Load(cq, items => items.Include(item => item.Id,
                item=>item.EffectiveBasePermissionsForUI,
                item=>item.EffectiveBasePermissions));

clientcontext.ExecuteQuery();

var itm  =  _list.GetItemById(itemid);
clientcontext.Load(itm, r => r.Id, r => r.DisplayName);
clientcontext.ExecuteQuery();


foreach (FileVersion itemVersion in itm.File.Versions)
{
  int size = itemVersion.Size;
  string versionlbl =  itemVersion.VersionLabel;
  string newversion = url + itemVersion.Url;
  System.WebClient client = new System.Net.WebClient();
  client.Credentials = new NetworkCredential(userid, f_SecurePass);
  System.IO.Stream Data = client.OpenRead(newversion);// Throws exception
}

如何下载列表项版本?

更新: 如果我尝试使用

下载文件版本

File.OpenBinaryDirect(客户端上下文,新版本); 它抛出以下错误

留言="Specified argument was out of the range of valid values.\r\nParameter name: serverRelativeUrl"

我可以使用更新 CSOM api 下载文件版本。

请参考 https://social.msdn.microsoft.com/Forums/en-US/802ecc6f-4a4d-4933-bf54-e68e5882203b/how-can-i-download-the-list-item-versions?forum=appsforsharepoint