title: How can I add an invoice to Xero?
body: <p>I managed to add a contact but when I try and add an invoice I get an error message 'A validation exception occurred'. I would appreciate suggestions as to what is causing this error.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      try
      {
          /// first create an instance of the Xero API
          var api = new Xero.Api.Example.Applications.Private.Core(false);
  
          Contact newContact = new Contact();
          newContact.Name = "Orac"; 
          Invoice newInvoice = new Invoice();
          newInvoice.Contact = new Contact();
          newInvoice.Contact = newContact;
          newInvoice.Date = System.DateTime.Now;
          newInvoice.DueDate = System.DateTime.Now.AddMonths(1);
          newInvoice.Status = Xero.Api.Core.Model.Status.InvoiceStatus.Authorised;
          newInvoice.Type = Xero.Api.Core.Model.Types.InvoiceType.AccountsReceivable;
          List&lt;LineItem&gt; lines = new List&lt;LineItem&gt;();
          LineItem li = new LineItem();
          li.LineAmount = Convert.ToDecimal("200.00");
          li.Quantity = Convert.ToDecimal("1.0000");
          li.ItemCode = "100";
          li.Description = "Webdev inv test";
          li.AccountCode = "200";
          li.UnitAmount = Convert.ToDecimal("50.00");
          lines.Add(li);
          newInvoice.LineItems = lines;
  
          // call the API to create the contact
          api.Invoices.Create(newInvoice);
          //api.Contacts.Create(newContact);
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message);
      }
  </code></pre>