Search code examples
intuit-partner-platform

QBO v2 API Invoice query goes boom


peeps! I'm attempting to load an invoice from Quickbooks online using v2 of the Java API with the following code:

    public String getInvoiceFoo(String docNumber, PlatformSessionContext context) throws QBInvalidContextException, Exception {
    QBInvoiceQuery query = new QBInvoiceQuery(context);
    query.setDocNumber(docNumber);
    QBInvoiceService invoiceService = QBServiceFactory.getService(context, QBInvoiceService.class);
    QBInvoice qbInvoice = invoiceService.getInvoices(context, query).get(0);
    return qbInvoice.getHeader().getDocNumber();
}

This seemingly simple query results in the following error:

Error: 400 <?xml version="1.0" encoding="UTF-8" standalone="yes"?><FaultInfo xmlns="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd"><Message>Search Criteria has invalid PropertyName: DocNumber</Message><ErrorCode>BAD_QUERY_REQUEST</ErrorCode><Cause>QUERY_INVALID_SEARCH_CRITERIA</Cause></FaultInfo>

The server seems to complain about DocNumber being an invalid property. Has anyone else successfully queried invoices by number?


Solution

  • Filtering by docnumber is not supported for Invoices in V2 QBO. Please refer: https://developer.intuit.com/docs/95_deprecated/qbo_v2/0400_qbo_v2_reference/invoice

    Please use V3 services for this.