Obtenga un error 401 al intentar descargar un documento de una biblioteca programáticamente
-
09-12-2019 - |
Pregunta
Estoy tratando de descargar un documento con este código:
using (Impersonator impersonator = new Impersonator())
{
siteURL += "?NoRedirect=true";
System.Net.WebClient _WebClient = new System.Net.WebClient();
// Downloads the resource with the specified URI to a local file.
_WebClient.DownloadFile(siteURL, saveName);
}
pero recibo un error 401 Acceso inoperante.¿Tienes alguna idea de dónde viene? Gracias
Solución
Intenta agregar:
_WebClient.Credentials = CredentialCache.DefaultCredentials;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a sharepoint.stackexchange