I am currently creating an integration with our in house invoicing system and looking to push invoices to Xero when they are created internally.
As we have our own invoices and invoice numbers we are currently running a check for the maximum invoice number in both, picking which is highest and using that as a base to ensure that invoice numbers are the same across both systems.
I have found the below examples https://community.xero.com/developer/discussion/115070444#answer115114688
also the 'Ordering of results' section on the official documentation: https://developer.xero.com/documentation/api/requests-and-responses
However I have tried multiple variations in my application but can't seem to get the right combination.
The link currently authenticates and creates / updates new contacts so everything else is currently going smoothly, below is my current code:
var invoices = await api.GetInvoicesAsync(token.AccessToken, xeroTenantId, where: "Type == \"ACCREC\"", order: "InvoiceNumber%20DESC", page: 1);
I get a QueryParseException each time with either 'Operator '%' incompatible with operand types 'String' and 'Int32'' or 'No property or field 'DESC' exists in type 'Invoice''
Is there anything I need to add here or is there an alternative way to get the 'Maximum invoice number' from Xero that I am not seeing?
Thanks in advance,
Thanks to @droopsnoot for the assistance on this one and all of the credit should go to him.
Posting the solution here for others to find.
As the 'where:' parameter isn't URL-encoded then it can just be passed with a normal space character.
var invoices = await api.GetInvoicesAsync(token.AccessToken, xeroTenantId, where: "Type == \"ACCREC\"", order: "InvoiceNumber DESC", page: 1);