Web client download data 401 unauthorized issue

HI,

I am downloading a files from WSS using the webclient.downloaddata method as below:

WebClient objhelper= new WebClient();

                                           

  objhelper.Credentials = source_credentials;

                                   byte[]   data = objhelper.DownloadData(FileUrl);

i have also specified the credentials. Most strange issue is it is working for some files and randomly throws this issue on objhelper.DownloadData(FileUrl) line.

Please suggest

August 18th, 2015 1:01pm

Hi varinder,

Please try to set UseDefaultCredentials to true. The following code snippet for your reference:

WebClient objhelper= new WebClient();
                                            
objhelper.Credentials = source_credentials;

objhelper.UseDefaultCredentials = true;

byte[] data = objhelper.DownloadData(FileUrl);

If the issue still exists, please use an admin user to download the files from SharePoint.

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 3:15am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics