Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am getting 401 unauhtorized issue,when I try to execute this "Stream stream = webClient.OpenRead(imageInformation.Url)" line;

I am giving the full piece of code for your reference.

using (WebClient webClient = new WebClient())
            {
                webClient.Credentials = new SharePointOnlineCredentials(ConfigSettings.VNextSiteUsername, password);
                webClient.Headers.Add(CommonConstants.Authentication, "f");

                if (imageInformation.Url != null)
                {
                    Stream stream = webClient.OpenRead(imageInformation.Url);

                    Bitmap bitmap = new Bitmap(stream);
                    stream.Flush();
                    stream.Close();
                    Directory.CreateDirectory(ConfigSettings.DownloadPath);
                    bitmap.Save(ConfigSettings.DownloadPath + imageInformation.GPNNumber + '.' + imageInformation.Extension);
                    Console.WriteLine("Profile pictures downloaded to local - " + imageInformation.GPNNumber + '.' + imageInformation.Extension);
                }
            }  


Please help me.


What I have tried:

I have tried disabling my proxy settings
I have checked my credentials also
It was working till now,all of a sudden after a month it is not working
Posted
Updated 10-May-18 2:48am

1 solution

try adding this line, this might help you

webClient.UseDefaultCredentials = true;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900