Download File from URL Activity: Response status code does not indicate success: 401 (Unauthorized)

Hi Guys,

I use Download File from URL Activity, download a txt file from a sharepoint link, have this error: Response status code does not indicate success: 401 (Unauthorized).
If I use HTTP request activity, use the same link, and or the other arguments keep the default, I will get correct response.
How can I fix this or use download file from URL Activity download this txt file.

BR,

The error 401 (Unauthorized) suggests that you are not authenticated when using the Download File from URL activity. Since you can get the correct response using the HTTP Request activity, it indicates that the SharePoint URL requires authentication.

To fix this:

  1. Authenticate: Ensure you are passing the correct credentials (such as API key, OAuth token, or session cookies) required to access the file from SharePoint.
  2. Use HTTP Request: If you can successfully retrieve the file using HTTP Request, continue using it and save the response to a file using the Write Text File activity.

Alternatively, ensure that Download File from URL supports authentication for SharePoint files.

Hi @Zeki_Berk_Gokkaya

thanks your reply.
Because the txt file maybe more than 100MB, So I think download file activity is best practice.

BR,

When you try it with the Download file from url, does it fail immediately or after a moment of downloading the file?

I am also curious - what is the Postman response tona GET request to your URL with the option for a redirect disabled? Does it differ with the redirect enabled?

Hi @loginerror

Because Sharepoint is On-prem, So I can’t use postman.
Are there have other ways?
It fail immediately.
If I access this url in Browser, It will not redirect and show the txt file content directly.

BR,

@donghai

  1. Is the url ending with .txt? Ideally download file from url needs some url like that
  2. If its sharepoint url also if http is working then it should not be a problem I believe…but ideally this si suprising to see http request working

Cheers

  1. yes, url ending with .txt.
  2. yes, on-prem sharepoint, and http request worked.

download file from url activity, does not have authentication attributes.

Hi, Maciej

Any new updates?

BR,

I am having some trouble reproducing this behaviour.

Could you please share a bit more details, such as the sharing configuration of your Sharepoint file within Sharepoint? Feel free to blur any sensitive info - it is only about the way this file is shared, so that I can try and recreate the same settings on my end.

Also, please confirm that you tried with the latest preview of the System activity package.

Lastly, some simple screenshots (once again - blur out anything sensitive) of how the activity is configured would be nice.

Hi Maciej

thanks your reply.
First, I have tried it the latest system activity, 24.11.0-preview, but have the same problem.
Second, I don’t know the way this file shared, How can I find this?
I want to confirm one thing, have you test download activity to download a file shared in Sharepoint?

BR,

Yes, I tested with a link that looks like this:
https://uipath-my.sharepoint.com/:t:/p/username/blablabla?download=1

That is also set to be accessible by anyone in Sharepoint:
A screenshot of "Link settings" for a file named "testTextFile" showing that the sharing option is set to "Anyone," allowing access without sign-in. (Captioned by AI)

And testing with such URL I am getting the file with both activities:


image

Hi

I have share the link for everyone, and have the same error.
And I have tested like blew code.

Dim httpRequest As HttpWebRequest = DirectCast(WebRequest.Create(“***.txt”), HttpWebRequest)
httpRequest.Method = WebRequestMethods.Http.Get
httpRequest.Credentials=System.Net.CredentialCache.DefaultCredentials
Dim httpResponse As HttpWebResponse = DirectCast(httpRequest.GetResponse(), HttpWebResponse)
Dim httpResponseStream As Stream = httpResponse.GetResponseStream()
Dim txt As Byte()
Dim ms As MemoryStream = New MemoryStream()
httpResponseStream.CopyTo(ms)
txt = ms.ToArray()
File.WriteAllBytes(“C:\ab.txt”, txt)

It’s OK, but If I comment out httpRequest.Credentials=System.Net.CredentialCache.DefaultCredentials , will have the same error.
So, can I guess that Download file activity does not integration credential?

BR,