By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

How to work ReSTFul API and C# application?

P: 1
I search it from other friend, but I cannot work too and have message no permission to access this web service.

Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3. try
  4.             {
  5.                 Uri uri = new Uri("http://localhost:8080/qcbin/authentication-point/authenticate");
  6.                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
  7.                 request.Method = "POST";
  8.                 NetworkCredential credentials = new NetworkCredential("user", "password");
  9.                 request.Credentials = credentials;
  10.  
  11.                 WebResponse v = request.GetResponse();
  12.                 Stream rStream = v.GetResponseStream();
  13.                 StreamReader str = new StreamReader(rStream);
  14.                 if (str.EndOfStream != true)
  15.                 {
  16.                     richTextBox1.Text = str.ReadToEnd();
  17.  
  18.                 }
  19.                 v.Close();
  20.                 rStream.Close();
  21.                 str.Close();
  22.                 richTextBox1.Text = "success";
  23.  
  24.             }
  25.  
  26.             catch (Exception ex)
  27.             {
  28.                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
  29.             }     
  30.         }
Jan 8 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.