Summary
The post() method has three issues that cause problems with certain QuickBooks API endpoints:
1. post() hardcodes Content-Type: application/json
The QuickBooks /invoice/{id}/send endpoint requires Content-Type: application/octet-stream. Since post() hardcodes application/json, send requests fail with:
ValidationFault: Required parameter DeliveryAddress.Address is missing in the request (code 2020)
Confirmed by the Intuit developer community and verified in production.
2. post() doesn't include minorversion
The minorversion property is set to '75' in the constructor and correctly used in getCompanyInfo(), but post() never appends it:
// getCompanyInfo - correct
const url = `...?minorversion=${this.minorversion}`;
// post - missing
const url = `${this.apiBaseUrl}/v3/company/${token.realm_id}${endpoint}`;
3. query() has a typo: minorverion
const url = `...&minorverion=${this.minorversion}`;
// ^^^^^^^^^^^ missing 's'
Minor version is silently ignored on all queries.
Suggested Fix
Allow post() to accept an optional contentType parameter and consistently append minorversion:
async post({ token, endpoint, body, contentType = 'application/json' }) {
token = await this.getValidToken(token);
const separator = endpoint.includes('?') ? '&' : '?';
const url = `${this.apiBaseUrl}/v3/company/${token.realm_id}${endpoint}${separator}minorversion=${this.minorversion}`;
const res = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${token.access_token}`,
Accept: 'application/json',
'Content-Type': contentType,
},
body: JSON.stringify(body),
});
return await res.json();
}
Happy to submit a PR. Environment: @balancer-team/quickbooks v0.0.18, QBO Production API, Node.js.
Summary
The
post()method has three issues that cause problems with certain QuickBooks API endpoints:1.
post()hardcodesContent-Type: application/jsonThe QuickBooks
/invoice/{id}/sendendpoint requiresContent-Type: application/octet-stream. Sincepost()hardcodesapplication/json, send requests fail with:Confirmed by the Intuit developer community and verified in production.
2.
post()doesn't includeminorversionThe
minorversionproperty is set to'75'in the constructor and correctly used ingetCompanyInfo(), butpost()never appends it:3.
query()has a typo:minorverionMinor version is silently ignored on all queries.
Suggested Fix
Allow
post()to accept an optionalcontentTypeparameter and consistently appendminorversion:Happy to submit a PR. Environment:
@balancer-team/quickbooksv0.0.18, QBO Production API, Node.js.