Я пытаюсь загрузить файл all_users.csv из GitHub Enterprise через vb.net, используя .net framework 4.5.2, и получаю следующую ошибку:
Удаленный сервер возвратил ошибку: (404) Not Found.
Мой код:
Module Module1
Sub Main()
Dim remoteUri As String = "https://ghe.webserver/stafftools/reports/all_users.csv"
Dim fileName As String = "all_users.csv"
Dim password As String = "PERSONALACCESSTOKEN"
Dim username As String = "USERNAME"
System.Net.ServicePointManager.Expect100Continue = True
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
Dim client As New System.Net.WebClient
client.Credentials = New System.Net.NetworkCredential(username, password)
client.DownloadFile(remoteUri, fileName)
End Sub
End Module
Ошибка возникает в строке client.DownloadFile(remoteUri, fileName)
с полным исключением
System.Net.WebException was unhandled
HResult=-2146233079
Message=The remote server returned an error: (404) Not Found.
Source=System
StackTrace:
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at System.Net.WebClient.DownloadFile(String address, String fileName)
at ConsoleApplication1.Module1.Main() in C:\Users\Admin\AppData\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 13
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Однако работает следующая команда Curl (как описано здесь: https://help.github.com/en/enterprise/2.17/admin/installation/site-admin-dashboard#reports):
curl -L -u USERNAME:PERSONALACCESSTOKEN --insecure https://ghe.webserver/stafftools/reports/all_users.csv