1

I have created a connection (works well) and now I'm setting-up the Invoice. When I debug it, at one of the lines it generates an error with the object not set to a reference.

Invoice inv = new Invoice();

inv.Date = DateTime.Now.Date;
inv.DueDate = DateTime.Now.Date.AddDays(30);
inv.Type = Xero.Api.Core.Model.Types.InvoiceType.AccountsReceivable;
inv.Status = Xero.Api.Core.Model.Status.InvoiceStatus.Draft;
inv.LineAmountTypes = Xero.Api.Core.Model.Types.LineAmountType.Inclusive; //ERROR HERE

inv.Contact.Name = tbCustomer.Text;

inv.LineItems = new List<LineItem>();
Tatranskymedved
  • 4,194
  • 3
  • 21
  • 47
  • 1
    Are you sure it's not giving you an object reference error when you try and set inv.Contact.Name before instantiating inv.Contact? Maybe try inv.Contact = new Contact(); first? – rustyskates Apr 26 '19 at 01:47
  • 1
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Tatranskymedved Apr 29 '19 at 06:54
  • Cool that might work inv.Contact = new Xero.Api.Core.Model.Contact(); – Robert Peter Bronstein Apr 30 '19 at 06:25

0 Answers0