2016-07-20 28 views
0

SharePoint Online Webサイトからユーザーのプロファイルイメージをダウンロードし、そのイメージをPPTに挿入する必要があります。このため、私は以下のC#コードを使用しています:C#を使用してSharePoint Online Webサイトからユーザーのプロファイルイメージをダウンロード

string userPhotoURL = "https://microsoft.sharepoint.com/_layouts/15/userphoto.aspx?size=M&[email protected]"; 
using (var client = new WebClient()) 
    { 
     client.Headers.Add("User-Agent: Other"); 
     client.Credentials = Utility.GetSharePointOnlineCredentials(); // includes username and SecureString password 
     client.DownloadFile(userPhotoURL, "D:\sample.jpg"); 
    } 
// More code to read the D:\sample.jpg and insert it into PPT 

しかし、上記は403応答を返しています。

注:サーバー側からこれを達成する必要があります。

答えて

0

私はこの問題を自分で解決しました。基本的には、以下のようにリクエストを送信する際に余分なヘッダーを追加しました:

client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f"); 
関連する問題