Xeroizer::ApiException : QueryParseException: No property or field 'inv_id' exists

174 views Asked by At

I am Trying to get all the invoices in a single API hit. Because, for every user having 100's of invoices.

It will exceed the API limit (Minute Limit: 60 calls in a rolling 60 second window).

I am trying to store all the invoice id into a single array and from that i will get the details of the user and then i loop the records locally and display it. It's the right way?

invoice_ids = user.estimates.select("invoice_id") || [] xero = Xeroizer::PrivateApplication.new(XERO_CONFIG["key"], XERO_CONFIG["secret"], XERO_CONFIG["path"], :rate_limit_sleep => 5)
invoices = ['795f789b-5958-xxxx-yyyy-48436dbe7757','987g389b-5958-xxxx-yyyy-68636dbe5589'] 
inv_id = invoice_ids.pluck(:invoice_id) 
invoices = xero.Invoice.all(:where => 'InvoiceID==inv_id')

Also, I am getting the following error:

Xeroizer::ApiException (QueryParseException: No property or field 'inv_id' exists in type 'Invoice')
1

There are 1 answers

0
NM Pennypacker On

Looks like the problem is that you're not interpolating the inv_ids correctly. You probably need to do something like this:

invoices = xero.Invoice.all(:where => "InvoiceID==\"#{inv_id}\"")

You may have to perform some additional formatting on the inv_id variable to make it a valid Xero string. https://github.com/waynerobinson/xeroizer#retrieving-data