Was tasked with getting this report out which exists in the back office. I assumed it would be an easy API call. But no. This makes this exercise needlessly wasteful. As a new dev coming to this API it is soul crushing to see an issue like this open for 5 years with not a single update from the API team, it does not bode well.
For those following on behind I was lucky that with some thinking outside the box I managed to find a way around it using the Invoice API to get all outstanding invoices that are over due. Hope this gives you some pointers.
First up I found the API Explorer really handy, I'll include the links to that here but you will have to sign in to see them.
Get all contacts who are active and customers (I don't care about suppliers):
I need to keep hold of this and use it as a look up in the next step when we get all invoices. Reason being that there is no way to filter the invoices to just Customers, they could be from suppliers too so in my code I have to manually filter out all invoices that aren't in this list of Contacts.
From there I managed to get a list of all outstanding invoices (all those with a status of "AUTHORISED") that have a due date over a week old (I generate out the current date in my api param:
So that is 2 requests per account instead of having to harvest everything per contact. Might not be exactly what you want but from that I was able to get what I needed. Thanks Xero for the loop jumping and the timely updates.
Was tasked with getting this report out which exists in the back office. I assumed it would be an easy API call. But no. This makes this exercise needlessly wasteful. As a new dev coming to this API it is soul crushing to see an issue like this open for 5 years with not a single update from the API team, it does not bode well.
For those following on behind I was lucky that with some thinking outside the box I managed to find a way around it using the Invoice API to get all outstanding invoices that are over due. Hope this gives you some pointers.
First up I found the API Explorer really handy, I'll include the links to that here but you will have to sign in to see them.
Get all contacts who are active and customers (I don't care about suppliers):
https://api-explorer.xero.com/accounting/contacts/getcontacts?query-where=ContactStatus%3D%3D%22ACTIVE%22+AND+IsCustomer%3D%3Dtrue&query-=
I need to keep hold of this and use it as a look up in the next step when we get all invoices. Reason being that there is no way to filter the invoices to just Customers, they could be from suppliers too so in my code I have to manually filter out all invoices that aren't in this list of Contacts.
From there I managed to get a list of all outstanding invoices (all those with a status of "AUTHORISED") that have a due date over a week old (I generate out the current date in my api param:
https://api-explorer.xero.com/accounting/invoices/getinvoices?query-statuses=AUTHORISED&query-where=DueDate+%3C%3D+%3C+DateTime%282021%2C+04%2C+01%29
So that is 2 requests per account instead of having to harvest everything per contact. Might not be exactly what you want but from that I was able to get what I needed. Thanks Xero for the loop jumping and the timely updates.