66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace csharpRestClient
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region UI Event Handler
|
|
private void cmdGO_Click(object sender, EventArgs e)
|
|
{
|
|
RestClient rClient = new RestClient();
|
|
rClient.endPoint = txtRequestURI.Text;
|
|
|
|
if (rdoRollOwn.Checked)
|
|
{
|
|
rClient.authTech = authenticationTechnique.RollYourOwn;
|
|
debugOutput("AuthTechnique: Roll Your Own");
|
|
debugOutput("AuthType: Basic"); // Will always be basic in this tutorial for roll your own
|
|
}
|
|
else
|
|
{
|
|
rClient.authTech = authenticationTechnique.NetworkCredential;
|
|
debugOutput("AuthTechnique: NetworkCredential");
|
|
debugOutput("AuthType: ??? - NetCred decides");
|
|
}
|
|
|
|
//rClient.authType = authenticationType.Basic;
|
|
rClient.userName = txtUserName.Text;
|
|
rClient.userPassword = txtPassword.Text;
|
|
|
|
debugOutput("REst Client Created");
|
|
string strResponse = string.Empty;
|
|
strResponse = rClient.makeRequest();
|
|
debugOutput(strResponse);
|
|
}
|
|
#endregion
|
|
|
|
private void debugOutput(string strDebugText)
|
|
{
|
|
try
|
|
{
|
|
System.Diagnostics.Debug.Write(strDebugText + Environment.NewLine);
|
|
txtResponse.Text = txtResponse.Text + strDebugText + Environment.NewLine;
|
|
txtResponse.SelectionStart = txtResponse.TextLength;
|
|
txtResponse.ScrollToCaret();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
System.Diagnostics.Debug.Write(ex.Message, ToString() + Environment.NewLine);
|
|
}
|
|
}
|
|
}
|
|
}
|