QbXML FAQ

From ConsoliBYTE Wiki
Jump to: navigation, search

Contents

What does "0x80040400 QuickBooks found an error when parsing the provided XML text stream." mean?

It means you have some sort of strange error in your qbXML request. Try running the your qbXML request through the QuickBooks qbXML test/validator utilities included in the QuickBooks SDK.

It's worth noting that order matters when building qbXML requests. For example, if the qbXML request is defined in the OSR like this:

 
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <CustomerAddRq>
      <CustomerAdd>
        <Name>STRTYPE</Name>
        <FirstName>STRTYPE</FirstName>
        <MiddleName>STRTYPE</MiddleName>
        <LastName>STRTYPE</LastName>
        ...
 

Then this will not work (because the <Name>…</Name> and <FirstName>…</FirstName> tags are in the opposite order):

 
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <CustomerAddRq>
      <CustomerAdd>
        <FirstName>Keith</FirstName>        
        <Name>Keith R Palmer</Name>
        <MiddleName>R</MiddleName>
        <LastName>Palmer</LastName>
        ...
 

Other common errors would include:

  • Leaving out required elements
  • Forgetting to close tags/really ugly, invalid XML streams
  • Sending non-ASCII or non-UTF-8 text (don't send strange, non-standard characters)
  • Sending XML attributes that should be escaped: & < >. These need to be converted to: & < > to include them in qbXML requests.

How can I troubleshoot qbXML errors?

  • Use the "XML Validator" tool included with the QuickBooks SDK. You can feed it an XML document, and it will tell you more or less exactly where the errors are.
  • Compare your XML (especially the order of the XML nodes) against the OSR:

http://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html

How can I get a list of deleted customers?

You can use the

 
ListDeletedQuery
 

query to fetch a list of deleted Customers (and other deleted object types).

How can I set the invoice number for an invoice?

You can set the invoice number for an invoice by setting the

 
<RefNumber>...</RefNumber>
 

tag in your qbXML InvoiceAddRq or InvoiceModRq. The returned TxnID tag is auto-generated by QuickBooks and cannot be set, but the RefNumber will be the one displayed in the QuickBooks GUI.

If you don't specify a RefNumber, QuickBooks will try to guess the next RefNumber based on the last previously created invoices' RefNumber field. (i.e. if the last invoice you added had a RefNumber of “5” then QuickBooks will assign the next invoice a RefNumber of “6” if you don't specify otherwise.)

How can I get a list of deleted invoices?

You can get a list of deleted invoices (and other transactions) by using the

 
TxnDeletedQuery
 

method. Here is some example qbXML:

 
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <TxnDeletedQueryRq>
      <!-- TxnDelType may have one of the following values: ARRefundCreditCard, Bill, BillPaymentCheck, BillPaymentCreditCard, BuildAssembly, Charge, Check, CreditCardCharge, CreditCardCredit, CreditMemo, Deposit, Estimate, InventoryAdjustment, Invoice, ItemReceipt, JournalEntry, PayrollLiabilityAdjustment [PRIVATE], PayrollPriorPayment [PRIVATE], PayrollYearToDateAdjustment [PRIVATE], PurchaseOrder, ReceivePayment, SalesOrder, SalesReceipt, SalesTaxPaymentCheck, TimeTracking, VehicleMileage, VendorCredit -->
      <TxnDelType>...</TxnDelType> <!-- required, may repeat -->
      <DeletedDateRangeFilter> <!-- optional -->
        <FromDeletedDate>DATETIMETYPE</FromDeletedDate> <!-- optional -->
        <ToDeletedDate>DATETIMETYPE</ToDeletedDate> <!-- optional -->
      </DeletedDateRangeFilter>
    </TxnDeletedQueryRq>
  </QBXMLMsgsRq>
</QBXML>
 

How can I send more than one request at once?

You can chain requests together to send more than one request at once. Here's an example:

 
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
 
    <CustomerAddRq requestID="Q3VzdG9tZXJBZGR8MTExMTIxMjE=">
      <CustomerAdd>
        <Name>Keith Palmer Jr.</Name>
        <FirstName>Keith</FirstName>
        <MiddleName></MiddleName>
        <LastName>Palmer Jr.</LastName>
        <BillAddress>
          <Addr1>134 Stonemill Road</Addr1>
          <City>Mansfield</City>
          <State>CT</State>
          <PostalCode>06268</PostalCode>
          <Country>USA</Country>
        </BillAddress>
        <Phone>999-99-9999</Phone>
        <Email>test@example.com</Email>
        <Contact>Keith Palmer Jr.</Contact>
      </CustomerAdd>
    </CustomerAddRq>
 
    <DataExtModRq>
      <DataExtMod>
        <OwnerID>0</OwnerID>
        <DataExtName>CustomerNumber</DataExtName>
        <ListDataExtType>Customer</ListDataExtType>
        <ListObjRef>
            <FullName>Keith Palmer Jr.</FullName>
        </ListObjRef>
        <DataExtValue>1234</DataExtValue>
      </DataExtMod>
    </DataExtModRq>
 
  </QBXMLMsgsRq>
</QBXML>
 

Here's another example, this one adds two items with a single qbXML request.

 
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="6.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
 
    <ItemNonInventoryAddRq requestID="1">
      <ItemNonInventoryAdd>
        <Name>Test Item 1</Name>
        <IsActive>true</IsActive>
        <SalesOrPurchase>
          <Desc>Test Item 1 Description</Desc>
          <Price>15.00</Price>
          <AccountRef>
            <FullName>Sales</FullName>
          </AccountRef>
        </SalesOrPurchase>
      </ItemNonInventoryAdd>
    </ItemNonInventoryAddRq>
 
    <ItemNonInventoryAddRq requestID="2">
      <ItemNonInventoryAdd>
        <Name>Test Item 2</Name>
        <IsActive>true</IsActive>
        <SalesOrPurchase>
          <Desc>Test Item 2 Description</Desc>
          <Price>25.00</Price>
          <AccountRef>
            <FullName>Sales</FullName>
          </AccountRef>
        </SalesOrPurchase>
      </ItemNonInventoryAdd>
    </ItemNonInventoryAddRq>
 
  </QBXMLMsgsRq>
</QBXML>