How to work ReSTFul API and C# application?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rithyph
    New Member
    • Jan 2013
    • 1

    How to work ReSTFul API and C# application?

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

    Code:
    private void button1_Click(object sender, EventArgs e)
            {
    try
                {
                    Uri uri = new Uri("http://localhost:8080/qcbin/authentication-point/authenticate");
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                    request.Method = "POST";
                    NetworkCredential credentials = new NetworkCredential("user", "password");
                    request.Credentials = credentials;
     
                    WebResponse v = request.GetResponse();
                    Stream rStream = v.GetResponseStream();
                    StreamReader str = new StreamReader(rStream);
                    if (str.EndOfStream != true)
                    {
                        richTextBox1.Text = str.ReadToEnd();
     
                    }
                    v.Close();
                    rStream.Close();
                    str.Close();
                    richTextBox1.Text = "success";
     
                }
     
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
                }     
            }
    Last edited by Meetee; Jan 8 '13, 10:03 AM. Reason: Use code tags <code/> around your code
Working...