Comments (6)
Hi @lancedfr, since this restriction is due to the overall character length of the request url you could provide the InvoiceNumber instead of the InvoiceId. InvoiceNumbers are typically shorter than InvoiceIds which are a GUID (36 characters).
from xero-openapi.
Hi @lancedfr, thanks for reporting this. I have transferred the issue over to our Open API Spec since the issue is happening at the API level and not specific to the Java SDK.
from xero-openapi.
https://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string
https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
from xero-openapi.
There is a bit about this in the Developer Centre docs
Retrieving a filtered set of resources
The number of parameters is only limited by the maximum url length. To ensure you receive a timely response from the API, we recommend you look to retrieve in a batch of 40.
https://developer.xero.com/documentation/api/accounting/requests-and-responses#retrieving-a-filtered-set-of-resources
from xero-openapi.
Hi @rdemarco-xero Thanks for this suggestion. We have updated our solution to retrieve invoices by InvoiceNumber instead of GUID. This still reaches the character length of the request parameter. We have been debugging the Xero JDK and found that the resolved URL being invoked is
As you can see InvoiceNumbers=
is being repeated.
When running the below HTTP GET command (after removing the repeated InvoiceNumbers=
) we manage to get all 100 invoices by number.
When running the below HTTP GET command (which is what the Xero JDK URL resolves to) we do not get all 100 invoices by number. Instead we get Response code: 404 (Not Found); Time: 826ms (826 ms); Content length: 47 bytes (47 B)
We still think this is an issue that should be resolved. Thanks @RettBehrens for the recommendation to fetch 40 invoices at a time, this still reaches the URL length limit for us (as our invoices numbers can be up to 9 chars long) because the Xero JDK makes the URL unnecessarily too long by duplicating InvoiceNumbers=
in the URL.
from xero-openapi.
When reviewing the java doc for the UriBuilder (the class the Xero JDK uses to build the URL) we can see the queryParam(String name, Object... values)
method states "If multiple values are supplied the parameter will be added once per value.". This causes the duplicating of InvoiceNumbers=
in the URL.
I managed to update the com.xero.api.client.AccountingApi
class to use String.join(",", invoiceNumbers)
to join the list of strings to a comma separated string (Which is what the API expects for InvoiceNumbers).
if (invoiceNumbers != null) {
String key = "InvoiceNumbers";
Object value = invoiceNumbers;
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, String.join(",", invoiceNumbers));
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
This works because one comma separated string is being passed into queryParam
method rather than multiple values. When testing this the resolved URL is now shorter and all 100 invoices are returned.
I believe the com.xero.api.client.AccountingApi
class is generated from a template and my fix won't work as is. I'm happy to implement this fix; I'm just not sure where your templates reside for me to fix.
from xero-openapi.
Related Issues (20)
- Missing POST BatchPayments
- Collect HOT 1
- Couldn't create Credit Card account through XERO Accounting API HOT 1
- Github actions test issue HOT 1
- Another github action test with account outside of org HOT 1
- Actions test HOT 2
- more testing HOT 2
- test test test HOT 2
- test
- test HOT 2
- Create Invoice is missing eInvoicing Field HOT 2
- Country in Organisation Address HOT 1
- Unable to build Go SDK from OpenAPI (failures in accounting schema) HOT 4
- Asset Type definition inconsistent with Xero interface HOT 2
- Asset depreciationStartDate not setting HOT 2
- Empty array with status 200 is returned when calling /connections endpoints HOT 4
- AU Payroll API LeaveApplicationID changes when a request is in Scheduled status HOT 3
- LineItems: DiscountRate returned but DiscountAmount does not depending on invoice call query HOT 2
- Organisation Class enum values need updated HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xero-openapi.