diff --git a/csharpRestClient.sln b/csharpRestClient.sln
new file mode 100644
index 0000000..6da9f35
--- /dev/null
+++ b/csharpRestClient.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30517.126
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharpRestClient", "csharpRestClient\csharpRestClient.csproj", "{9E4DEFFF-8371-4E80-9925-E4E5053F2FBE}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9E4DEFFF-8371-4E80-9925-E4E5053F2FBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9E4DEFFF-8371-4E80-9925-E4E5053F2FBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9E4DEFFF-8371-4E80-9925-E4E5053F2FBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9E4DEFFF-8371-4E80-9925-E4E5053F2FBE}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {3F593510-B46C-4628-931C-9BE764A1EB11}
+ EndGlobalSection
+EndGlobal
diff --git a/csharpRestClient/App.config b/csharpRestClient/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/csharpRestClient/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csharpRestClient/Form1.Designer.cs b/csharpRestClient/Form1.Designer.cs
new file mode 100644
index 0000000..5a660d1
--- /dev/null
+++ b/csharpRestClient/Form1.Designer.cs
@@ -0,0 +1,244 @@
+namespace csharpRestClient
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.txtRequestURI = new System.Windows.Forms.TextBox();
+ this.txtResponse = new System.Windows.Forms.TextBox();
+ this.cmdGO = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.txtUserName = new System.Windows.Forms.TextBox();
+ this.txtPassword = new System.Windows.Forms.TextBox();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.rdoBasicAuth = new System.Windows.Forms.RadioButton();
+ this.rdoNTLMAuth = new System.Windows.Forms.RadioButton();
+ this.rdoRollOwn = new System.Windows.Forms.RadioButton();
+ this.rdoNetCred = new System.Windows.Forms.RadioButton();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // txtRequestURI
+ //
+ this.txtRequestURI.Location = new System.Drawing.Point(123, 24);
+ this.txtRequestURI.Name = "txtRequestURI";
+ this.txtRequestURI.Size = new System.Drawing.Size(328, 20);
+ this.txtRequestURI.TabIndex = 0;
+ //
+ // txtResponse
+ //
+ this.txtResponse.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txtResponse.Location = new System.Drawing.Point(123, 172);
+ this.txtResponse.Multiline = true;
+ this.txtResponse.Name = "txtResponse";
+ this.txtResponse.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.txtResponse.Size = new System.Drawing.Size(473, 194);
+ this.txtResponse.TabIndex = 1;
+ //
+ // cmdGO
+ //
+ this.cmdGO.Location = new System.Drawing.Point(457, 22);
+ this.cmdGO.Name = "cmdGO";
+ this.cmdGO.Size = new System.Drawing.Size(75, 23);
+ this.cmdGO.TabIndex = 2;
+ this.cmdGO.Text = "GO";
+ this.cmdGO.UseVisualStyleBackColor = true;
+ this.cmdGO.Click += new System.EventHandler(this.cmdGO_Click);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 27);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(69, 13);
+ this.label1.TabIndex = 3;
+ this.label1.Text = "Request URI";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 172);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(60, 13);
+ this.label2.TabIndex = 4;
+ this.label2.Text = "Responses";
+ //
+ // txtUserName
+ //
+ this.txtUserName.Location = new System.Drawing.Point(223, 52);
+ this.txtUserName.Name = "txtUserName";
+ this.txtUserName.Size = new System.Drawing.Size(100, 20);
+ this.txtUserName.TabIndex = 5;
+ //
+ // txtPassword
+ //
+ this.txtPassword.Location = new System.Drawing.Point(432, 52);
+ this.txtPassword.Name = "txtPassword";
+ this.txtPassword.PasswordChar = '*';
+ this.txtPassword.Size = new System.Drawing.Size(100, 20);
+ this.txtPassword.TabIndex = 6;
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.rdoNTLMAuth);
+ this.groupBox1.Controls.Add(this.rdoBasicAuth);
+ this.groupBox1.Location = new System.Drawing.Point(123, 78);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(200, 88);
+ this.groupBox1.TabIndex = 7;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Auth type";
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.rdoNetCred);
+ this.groupBox2.Controls.Add(this.rdoRollOwn);
+ this.groupBox2.Location = new System.Drawing.Point(355, 78);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(177, 88);
+ this.groupBox2.TabIndex = 8;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Technique";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(373, 55);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(53, 13);
+ this.label3.TabIndex = 9;
+ this.label3.Text = "Password";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(120, 55);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(29, 13);
+ this.label4.TabIndex = 10;
+ this.label4.Text = "User";
+ //
+ // rdoBasicAuth
+ //
+ this.rdoBasicAuth.AutoSize = true;
+ this.rdoBasicAuth.Checked = true;
+ this.rdoBasicAuth.Location = new System.Drawing.Point(6, 31);
+ this.rdoBasicAuth.Name = "rdoBasicAuth";
+ this.rdoBasicAuth.Size = new System.Drawing.Size(122, 17);
+ this.rdoBasicAuth.TabIndex = 0;
+ this.rdoBasicAuth.TabStop = true;
+ this.rdoBasicAuth.Text = "Basic Authentication";
+ this.rdoBasicAuth.UseVisualStyleBackColor = true;
+ //
+ // rdoNTLMAuth
+ //
+ this.rdoNTLMAuth.AutoSize = true;
+ this.rdoNTLMAuth.Location = new System.Drawing.Point(6, 54);
+ this.rdoNTLMAuth.Name = "rdoNTLMAuth";
+ this.rdoNTLMAuth.Size = new System.Drawing.Size(108, 17);
+ this.rdoNTLMAuth.TabIndex = 1;
+ this.rdoNTLMAuth.TabStop = true;
+ this.rdoNTLMAuth.Text = "NTLM (Windows)";
+ this.rdoNTLMAuth.UseVisualStyleBackColor = true;
+ //
+ // rdoRollOwn
+ //
+ this.rdoRollOwn.AutoSize = true;
+ this.rdoRollOwn.Checked = true;
+ this.rdoRollOwn.Location = new System.Drawing.Point(7, 31);
+ this.rdoRollOwn.Name = "rdoRollOwn";
+ this.rdoRollOwn.Size = new System.Drawing.Size(93, 17);
+ this.rdoRollOwn.TabIndex = 0;
+ this.rdoRollOwn.TabStop = true;
+ this.rdoRollOwn.Text = "Roll Your Own";
+ this.rdoRollOwn.UseVisualStyleBackColor = true;
+ //
+ // rdoNetCred
+ //
+ this.rdoNetCred.AutoSize = true;
+ this.rdoNetCred.Location = new System.Drawing.Point(7, 55);
+ this.rdoNetCred.Name = "rdoNetCred";
+ this.rdoNetCred.Size = new System.Drawing.Size(143, 17);
+ this.rdoNetCred.TabIndex = 1;
+ this.rdoNetCred.TabStop = true;
+ this.rdoNetCred.Text = "Network Credential Class";
+ this.rdoNetCred.UseVisualStyleBackColor = true;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(608, 378);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.txtPassword);
+ this.Controls.Add(this.txtUserName);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.cmdGO);
+ this.Controls.Add(this.txtResponse);
+ this.Controls.Add(this.txtRequestURI);
+ this.Name = "Form1";
+ this.Text = "c# REST Client";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox txtRequestURI;
+ private System.Windows.Forms.TextBox txtResponse;
+ private System.Windows.Forms.Button cmdGO;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox txtUserName;
+ private System.Windows.Forms.TextBox txtPassword;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.RadioButton rdoNTLMAuth;
+ private System.Windows.Forms.RadioButton rdoBasicAuth;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.RadioButton rdoNetCred;
+ private System.Windows.Forms.RadioButton rdoRollOwn;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ }
+}
+
diff --git a/csharpRestClient/Form1.cs b/csharpRestClient/Form1.cs
new file mode 100644
index 0000000..bb3a6f1
--- /dev/null
+++ b/csharpRestClient/Form1.cs
@@ -0,0 +1,65 @@
+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);
+ }
+ }
+ }
+}
diff --git a/csharpRestClient/Form1.resx b/csharpRestClient/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/csharpRestClient/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/csharpRestClient/Program.cs b/csharpRestClient/Program.cs
new file mode 100644
index 0000000..a2df165
--- /dev/null
+++ b/csharpRestClient/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace csharpRestClient
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/csharpRestClient/Properties/AssemblyInfo.cs b/csharpRestClient/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d46bcaf
--- /dev/null
+++ b/csharpRestClient/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("csharpRestClient")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("csharpRestClient")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("9e4defff-8371-4e80-9925-e4e5053f2fbe")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/csharpRestClient/Properties/Resources.Designer.cs b/csharpRestClient/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..b51c36d
--- /dev/null
+++ b/csharpRestClient/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace csharpRestClient.Properties
+{
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("csharpRestClient.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/csharpRestClient/Properties/Resources.resx b/csharpRestClient/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/csharpRestClient/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/csharpRestClient/Properties/Settings.Designer.cs b/csharpRestClient/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..ce6fc56
--- /dev/null
+++ b/csharpRestClient/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace csharpRestClient.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/csharpRestClient/Properties/Settings.settings b/csharpRestClient/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/csharpRestClient/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/csharpRestClient/RestClient.cs b/csharpRestClient/RestClient.cs
new file mode 100644
index 0000000..be02093
--- /dev/null
+++ b/csharpRestClient/RestClient.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace csharpRestClient
+{
+ // https://docs.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest?view=netcore-3.1
+ public enum httpVerb
+ {
+ GET,
+ POST,
+ PUT,
+ DELETE
+ }
+
+ public enum authenticationType
+ {
+ Basic,
+ NTLM
+ }
+
+ public enum authenticationTechnique
+ {
+ RollYourOwn,
+ NetworkCredential
+ }
+
+ public class RestClient
+ {
+ public string endPoint { get; set; }
+ public httpVerb httpMethod { get; set; }
+ public authenticationType authType { get; set; }
+ public authenticationTechnique authTech { get; set; }
+ public string userName { get; set; }
+ public string userPassword { get; set; }
+
+ public RestClient()
+ {
+ endPoint = string.Empty;
+ httpMethod = httpVerb.GET;
+ }
+
+ public string makeRequest()
+ {
+ string strResponseValue = string.Empty;
+
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endPoint);
+ request.Method = httpMethod.ToString();
+
+ string authHeader = System.Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(userName + ":" + userPassword));
+ request.Headers.Add("Authorization", authType.ToString() + " " + authHeader);
+
+ HttpWebResponse response = null;
+
+ try
+ {
+ response = (HttpWebResponse)request.GetResponse();
+
+ // Process the response stream... (could be JSON, XML or HTML etc...)
+ using(var responseStream = response.GetResponseStream())
+ {
+ if (responseStream != null)
+ {
+ using(var reader = new StreamReader(responseStream))
+ {
+ strResponseValue = reader.ReadToEnd();
+
+ }//End of StreamReader
+ }
+ }//End of using ResponseStream
+
+ }//End of using response
+ catch(Exception ex)
+ {
+ strResponseValue = "{\"errorMessages\":[\"" + ex.Message.ToString() + "\"],\":{}}";
+ }
+ finally
+ {
+ if (response != null)
+ {
+ ((IDisposable)response).Dispose();
+ }
+ }
+ return strResponseValue;
+ }
+
+ }
+}
diff --git a/csharpRestClient/csharpRestClient.csproj b/csharpRestClient/csharpRestClient.csproj
new file mode 100644
index 0000000..2ba0f29
--- /dev/null
+++ b/csharpRestClient/csharpRestClient.csproj
@@ -0,0 +1,84 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {9E4DEFFF-8371-4E80-9925-E4E5053F2FBE}
+ WinExe
+ csharpRestClient
+ csharpRestClient
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file