我从 Delve 帐户获取个人资料图片时遇到问题。这是我将照片放入浏览器时返回照片的链接示例:https ://orgname.sharepoint.com/_vti_bin/DelveApi.ashx/people/profileimage?userId=alias@org.com&size=L
现在我需要从代码中获取这张照片。我试过这样的方法,它非常适合不在 Office365 中的外部图像:
var credentials = new NetworkCredential("myemail", "password");
using (var handler = new HttpClientHandler { Credentials = credentials })
using (var client = new HttpClient(handler))
{
var bytes = await client.GetByteArrayAsync(url);
return Convert.ToBase64String(bytes);
}
但是作为回应,我得到了带有如下文本的html页面:
<H1>We can't sign you in</H1><p>Your browser is currently set to block cookies. You need to allow cookies to use this service.</p><p>Cookies are small text files stored on your computer that tell us when you're signed in. To learn how to allow cookies, check the online help in your web browser.</p>
我认为它与 Office365 授权有关,但我不知道如何使用我的凭据对该 url 执行 REST 请求...