1

I'm using the Xero API to post multiple invoices to Xero.

This works fine if all the invoices are valid. I get a HTTP 200 response with the GUIDs of the newly created invoices.

However, if one of the invoices has an error I get a BadRequest response with a ValidationException.

I would expect the xero system to work transactionally, and if any of the invoices have a validation error, then none of them would be created. However, what I'm observing is that the valid invoices from my request are still created in the system, even when there is an invalid one present in the request.

The problem is that the response from the Xero API just has the details of the validation error. Nowhere in the response do I get the details of the newly created valid invoices. So I have no way of knowing what the GUIDs of those new invoices are.

Has anyone else experienced a problem like this, and how did they overcome it?

I am reluctant to send the invoices individually as their own guidance recommends posting multiple entities at once to avoid exceeding the rate limits of the API.

Tom
  • 129
  • 1
  • 4
  • 11

1 Answers1

2

By default, the Xero API returns a "summarized" view of your errors when one or more resources in a PUT/POST request are invalid.

If you take a look at the Creating many resources section on this page of our docs you'll see an example of how to turn this off using the query parameter ?SummarizeErrors=false.

Cheers, Matt

MJMortimer
  • 865
  • 5
  • 10
  • Thank you so much. I had seen the part about SummarizeErrors on the Invoice API docs, but hadn't twigged the link between that and the details of the valid invoices being in the response. – Tom Oct 09 '18 at 08:38