Search code examples
phpxmlquickbooksqbxml

Quickbooks web connector give parsing error when trying to add invoice with field InventorySiteRef


Quickbooks web connector give parsing error when trying to add invoice with field InventorySiteRef.

0x80040400: QuickBooks found an error when parsing the provided XML text stream.

Below is my XML stream.

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
    <QBXMLMsgsRq onError="continueOnError">
    <InvoiceAddRq requestID="' . $requestID . '">
        <InvoiceAdd>
            <CustomerRef>
                <ListID>' . $invoice['customer_id'] . '</ListID>
            </CustomerRef>
            <RefNumber>' . $invoice['ref_number'] . '</RefNumber>
            <BillAddress>
                <Addr1>' . $invoice['bill_addr1'] . '</Addr1>
                <Addr2>' . $invoice['bill_addr2'] . '</Addr2>
                <Addr3>' . $invoice['bill_addr3'] . '</Addr3>
                <Addr4>' . $invoice['bill_city'] . '</Addr4>
                <State>' . $invoice['bill_state'] . '</State>
                <PostalCode>' . $invoice['bill_postalcode'] . '</PostalCode>
            </BillAddress>
            <ShipAddress>
                <Addr1>' . $invoice['ship_addr1'] . '</Addr1>
                <Addr2>' . $invoice['ship_addr2'] . '</Addr2>
                <Addr3>' . $invoice['ship_addr3'] . '</Addr3>
                <Addr4>' . $invoice['ship_city'] . '</Addr4>
                <State>' . $invoice['ship_state'] . '</State>
                <PostalCode>' . $invoice['ship_postalcode'] . '</PostalCode>
            </ShipAddress>
            <PONumber>' . $invoice['po_number'] . '</PONumber>
            <DueDate>' . $invoice['due_date'] . '</DueDate>
            <ShipDate>' . $invoice['ship_date'] . '</ShipDate>
            <Memo>' . $invoice['memo'] . '</Memo>
            <InvoiceLineAdd>
                <ItemRef>
                    <FullName>'.$line['item_name'].'</FullName>
                </ItemRef>
                <Quantity>'.$line['quantity'].'</Quantity>
                <Rate>'.$line['rate'].'</Rate>
                <Amount>'.$line['amount'].'</Amount>
                <InventorySiteRef>
                    <FullName>Odessa</FullName>
                </InventorySiteRef>
                <InventorySiteLocationRef>
                    <FullName>Odessa</FullName>
                </InventorySiteLocationRef>
            </InvoiceLineAdd>
        </InvoiceAdd>
    </InvoiceAddRq>
</QBXMLMsgsRq>

I also tried with only

<InventorySiteRef>
    <FullName>Odessa</FullName>
</InventorySiteRef>

And also tried with only

<InventorySiteLocationRef>
    <FullName>Odessa</FullName>
</InventorySiteLocationRef>

When I tried to add an invoice without InventorySiteRef and InventorySiteLocationRef Tag's Invoice created successfully

I think InventorySiteRef is not define, somewhere in QuickBooks consolibyte PHP DevKit.


Solution

  • Enable verbose logging and look at what QBXML is actually being generated. The QBXML will be in the log file. https://help.developer.intuit.com/s/article/QBD-QBSDK-Logging

    Take the QBXML being generated and run that through the validator program included with the QBXML SDK.

    Make sure you have the order of the tags correct and that it matches the Onscreen Reference Guide. https://developer-static.intuit.com/qbsdk-current/common/newosr/index.html