title: How to authenticate with RestSharp
body: <p>I would like to authenticate me on spreadshirt but I get an internal server error as result.</p>
  
  <p>Im new to Rest API..</p>
  
  <p>So here is the documentation: <a href="https://developer.spreadshirt.net/display/API/Security+Resources" rel="nofollow noreferrer">https://developer.spreadshirt.net/display/API/Security+Resources</a></p>
  
  <p>and my Code: </p>
  
  <pre><code>        var client = new RestClient("https://api.spreadshirt.net/api/v1");
  
          var request = new RestRequest("sessions", Method.POST);
          request.AddParameter("username", "foo");
          request.AddParameter("password", "bar");
          var test = client.Execute(request);
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Got it</p>
  
  <p>My Login Class</p>
  
  <pre><code>[SerializeAs(Name ="login")]
  public class Login
  {
      private string user;
      private string pw;
  
  
      [SerializeAs(Name ="username")]
      public string username
      {
          get
          {
              return "foo";
          }
          set
          {
              this.user = value;
          }
      }
      [SerializeAs(Name ="password")]
      public string password
      {
          get { return "bar"; }
          set { this.pw = value; }
      }
  }
  </code></pre>
  
  <p>On Button Click</p>
  
  <pre><code>var login = new Login();
          var request = new RestRequest("sessions/", Method.POST);
  
          var client = new RestClient("https://api.spreadshirt.net/api/v1/");
  
          request.XmlSerializer = new RestSharp.Serializers.XmlSerializer();
          request.RequestFormat = DataFormat.Xml;
  
          request.AddXmlBody(login, "http://api.spreadshirt.net");
  
          var response = client.Execute(request);
          MessageBox.Show(response.StatusCode.ToString());
  </code></pre>