Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Invoice line items not coming through with the .Net API wrapper

Started by Rebecca Gordon -   in API Endpoints

Hi guys,

I'm using the .Net wrapper and pulling back invoices from Xero using the following

IQueryable<Invoice> invoicesList = GetXeroInvoices(repository);
if (invoicesList != null)
{
foreach (Invoice lcInvoice in invoicesList)
{
...
if (lcInvoice.LineItems != null && lcInvoice.LineItems.Count > 0)
{
...

All invoices return a LineItems.Count of 0, is there something obvious I'm doing wrong? Or is it a bug?

Kind regards,


Rebecca
I've noticed this as well. Using the previewer at api.xero.com seems to reveal that the LineItems are not returned as part of the XML. Have you tried to use that to see if you have the same problem?
 

Matthew Steeples  

Hi Mathew, thanks for your response.

I just tried the previewer and can confirm that no line items are being returned there either.

Hmm, I'll wait a couple of more days and see if anyone from the API team responds, if not I'll give them a call. I'll post back here when I find a resolution.

Kind regards,

Rebecca
 

Rebecca Gordon  

The answer is:

This is actually an expected behaviour, not a bug.
When you retrieve multiple invoices, only a summary of the contact is returned and no line details are returned - this is to keep the response more compact.
The line item details will be returned when you retrieve an individual invoice only, either by specifying Invoice ID or Invoice Number.
- Thank you Xero for responding so quickly :).

It's good to know this. In the loop I will simply use the invoices GUID to pull back individual invoice and extract the details and line items. A lot more calls to the API... hopefully won't be to much of a performance hit.
 

Rebecca Gordon  

Thanks for sharing that back here, as that's what I'm going to have to do as well. I think it's worth mentioning at this point the 60 calls per minute limitation and to watch out for it.
 

Matthew Steeples  

It was actually specified in the documentation about the limited data returned when getting all invoices.. woops. Credit notes and Bank Transactions are the same.

Yes I hit the cap today whilst trying to pull in all invoices and then all invoices again with line items.. Will have to stage the download of all data.... Also 1000 calls per day, plenty if your incrementing the synchronisation over time and just updating bits and pieces, but if you need to pull it all down to start with a bit harder.
 

Rebecca Gordon