Created
September 22, 2011 06:27
-
-
Save XeroAPI/1234181 to your computer and use it in GitHub Desktop.
Sample code to show capturing a validation error in the XeroAPI.Net wrapper library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Try and create an invoice - but using incorrect data. This should hopefully be rejected by the Xero API | |
Invoice invoiceToCreate = new Invoice | |
{ | |
Contact = contact, | |
Type = "ACCREC", | |
Date = DateTime.Today, | |
LineItems = new LineItems | |
{ | |
new LineItem | |
{ | |
AccountCode = "200", | |
Description = "Blue Widget", | |
UnitAmount = 10m, | |
TaxAmount = 2m, | |
LineAmount = 12m | |
} | |
} | |
}; | |
var createdInvoice = repository.Create(invoiceToCreate); | |
if (createdInvoice.ValidationStatus == ValidationStatus.ERROR) | |
{ | |
foreach (var message in createdInvoice.ValidationErrors) | |
{ | |
Console.WriteLine("Validation Error: " + message.Message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment