Getting error while downloading of a file from a sharepoint

Hi Folks,

I am trying to download a file from a sharepoint inside a server, the bot is able to connect to the sharepoint and locate the file and able to read the file but when it comes to download the file I am getting the below error

"Download File: Code: generalException
Message: An error occurred sending the request.
"

The same code is working in the other VM but not on this one, I tried to open the sharepoint on chrome and was able to download the file but when trying with UiPath activities it’s not happening.

Also I am using Microsoft Office 365 Scope classic

Any help would be highly appreciated, looking forward for the response

Hi @pradyumn.agrawal1

The error usually happens because the VM has network, proxy, or firewall settings blocking UiPath’s API calls to SharePoint, even if the browser works.

Check that the Office 365 Scope authentication token is valid on this VM, confirm robot permissions, and ensure the UiPath Office 365 package versions match. Also, verify if any proxy or firewall is blocking requests from UiPath.

Hi Thanks for replying,

If there is any network blocker or any proxy setting then it would not allow the bot to connect the sharepoint.
My bot is able to connect to URL and locate the file, able to read the file name only thing is while downloading the file I am getting the error.
So do you have any idea why it could happen?

Hi @pradyumn.agrawal1

Since your bot can find the file but fails to download, possible reasons are file size/timeouts, download permissions or locks, network throttling by SharePoint, or invalid file paths.

Try with a smaller file, add retries, check filenames for invalid characters, or use SharePoint HTTP request as a workaround. Also, ensure your Office 365 activities package is up to date.

@pradyumn.agrawal1

The exception occurs when there is issue with your O365 app id, tenent etc.

Refer this:

Hi @pradyumn.agrawal1

Ensure Azure AD app permissions and admin consent: Files.ReadWrite.All, Sites.Read.All, offline_access; refresh tokens on that VM.
Check network on the failing VM: proxy/Firewall/SSL inspection allowing graph.microsoft.com and your SharePoint site over 443; ensure TLS 1.2 enabled.Clear cached creds/tokens on this VM and sign in again.
If using cert/secret auth, confirm the Robot service account can read the certificate in its store.
Happy Automation

Hi Thanks for replying,

I tried to use the inner exception and got the below error

System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (*****.sharepoint.com:443)
—> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
— End of inner exception stack trace —
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at Microsoft.Graph.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Graph.RetryHandler.SendAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken)
at Microsoft.Graph.CompressionHandler.SendAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken)
at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)

@pradyumn.agrawal1

as per error looks like the network issue but as you said as its working to get files etc it might not be the case..but the below inner exception looks skeptical..so can you check if there are firewall blocks on this port 443

Apart from that is it only the download activity that is causing issue? upload, get files, write to sharepoint list all are working?

can you also check event viewer logs when it fails…

If there are multiple users on the machine is it happening with all? if so generally while working with azure we can restrict based on VM as well so check on those line as well

Also very rare..but just deleting the activity and closing it and reopening and adding same activity fixes it..(I know its ridiculous but it did work many times :P)

cheers