Click here to Skip to main content
15,867,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i want to read data from a server by this code
C#
WebRequest req = WebRequest.Create("https://api.test/" + mytoken);
           req.UseDefaultCredentials = true;
           req.PreAuthenticate = true;
           req.Credentials = CredentialCache.DefaultCredentials;

           WebResponse resp = req.GetResponse();
           Stream stream = resp.GetResponseStream();
           StreamReader sr = new StreamReader(stream);
           string s = sr.ReadToEnd();
           sr.Close();

           TextBox1.Text = s;




this site give me my data correctly in all browser without any username and password but in my website i receive error about Unauthorized state
what must i do ?
Posted
Updated 22-Jul-15 22:39pm
v2
Comments
Praveen Kumar Upadhyay 23-Jul-15 4:56am    
Your token is not valid to authenticate. Please check with the API provider.
Bernhard Hiller 23-Jul-15 5:22am    
Did you store your username/password in your browser?
ZurdoDev 23-Jul-15 8:17am    
Whatever the default credentials are now, they don't have permissions.

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