1

Using the Microsoft Graph C# SDK, I've gotten the DriveItem of a file a want:

DriveItem myDriveItem = await graphClient 
 .Sites[targetSite.Id]
 .Lists[targetList.Id]
 .Drive
 .Items[targetItem.Id]
 .Request()
 .GetAsync();

Using the download link in it returns Error 407: Proxy Authentication Required.

using (var client = new WebClient())
{
   outputText = client.DownloadString((string)myDriveItem
                      .AdditionalData["@microsoft.graph.downloadUrl"]);
}

If it helps, I'm trying to download an XML file from a Sharepoint form library. The link works when I use it in a browser. How do I download the file?

4

1 回答 1

0

Solved using answers from WebProxy error: Proxy Authentication Required

It requires setting up the proxy of the WebClient.

IWebProxy defaultWebProxy = WebRequest.DefaultWebProxy;
defaultWebProxy.Credentials = CredentialCache.DefaultCredentials;
WebClient client = new WebClient
{
    Proxy = defaultWebProxy
};

var dataString = client.DownloadString((string)mydriveItem.AdditionalData["@microsoft.graph.downloadUrl"]);
于 2019-03-09T01:06:48.067 回答