Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Invoice API not accepting my JSON

Started by Thomas Lea -   in API Endpoints

I am sending a JSON object to the invoice endpoint to create an invoice, it is all working fine, except for one line where Im using a string added to an input element's value, like below.

invoiceJSON.InvoiceNumber = "INV-" + document.getElementById("example").value;

If I console.log the resulting JSON and put it into the previewer it works fine. Also my app's api shows response 200 and an invoice id is created, but crucially no invoice is created in Xero.

Without the above line it works perfectly and if I use just the string or just the input element's value it also works fine.

I am completely lost for ideas about why this isnt working.
Thomas, any chance you already have an invoice with that number, and it's just overwriting it?

Perhaps you're expecting a new invoice to turn up in the Draft section, but an existing one is hiding under Awaiting approval or similar?

Robert Sinton  

Hi Robert, I have worked out the problem. I think it is the email validation that xero uses. I have a user filled email field and I think that when I wasnt filling that out correctly during testing it was causing a problem as it tried to add it to the contact as it created the invoice.
Hopefully all sorted now.

Thomas Lea  

I am having a similar issue ,
I can add an invoice with out email , but.. not cool.
When I add the email as whatever@company.com - it seems to fail on the address.
where do we find the validation process XERO are using ?

Scott Snowball