我正在构建一个 Windows 应用商店应用程序,我必须在其中从 SharePoint 2013 站点上传和下载图像。我尝试了 REST API,但我得到的只是包含文件属性的 XML 数据,但我无法获取实际文件。有人可以帮我吗?
以下是我正在尝试的代码:
HttpClientHandler handler = new HttpClientHandler();
handler.UseDefaultCredentials = false;
handler.Credentials = new NetworkCredential(userName, password, domain);
HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Accept", "application/atom+xml");
client.DefaultRequestHeaders.Add("ContentType", "application/atom+xml;type=entry");
var response = await client.GetAsync("server/site/_api/web/ListName/Items(1)/File");
Byte[] bArray = await response.Content.ReadAsByteArrayAsync();