2017-12-12 19 views
0

私の質問はsharepoint onlineについてです。 私のプロジェクトでは、そのバージョンのリスト項目をダウンロードしたいと思っています。現在のリストアイテムのバージョンはダウンロードできますが、バージョンはダウンロードできません。私は、CanonicalとRevisionのパスを計算する方法を示すthis answerを参照しました。しかし、データを取得中にエラーが表示されるリストアイテムのバージョンをダウンロードするにはどうすればいいですか?

リモートサーバーからエラーが返されました。(403)禁止されています。

および応答ヘッダーで「アクセスが拒否されました。この場所のファイルを開く前に、まずWebサイトを参照して、自動的にログインするオプションを選択する必要があります。

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 
} 

リストアイテムのバージョンはどのようにダウンロードできますか?

UPDATE:私は

File.OpenBinaryDirect(CLIENTCONTEXT、NEWVERSION)を使用してファイルのバージョンをダウンロードしようとします。 それは

メッセージ=「指定された引数が有効な値の範囲外でした\ rを\名前nParameter。:serverRelativeUrl」次のエラーがスローされます

+0

を参照してくださいhttps://test.sharepoint.com/teams/Mycompany/_vti_history/512/Sharedドキュメント/ MY CODE.docx – Mayuresh

答えて

関連する問題