How to modify an invoice in quickbooks using qbxml

2019-06-02 16:59发布

问题:

This is my QBXML request

<?xml version="1.0" ?>
<?qbxml version="6.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
        <InvoiceModRq requestID="1">
            <InvoiceMod>
                <TxnID>85-1442639879</TxnID>
                <EditSequence>1442639879</EditSequence>
                <CustomerRef>
                    <ListID>80000005-1442639850</ListID>
                    <FullName>Bruce Banner</FullName>
                </CustomerRef>
                <TxnDate>2015-09-19</TxnDate>
                <RefNumber>5462</RefNumber>
                <InvoiceLineMod>
                    <ItemRef>
                        <ListID>8000000A-1442469770</ListID>
                        <FullName>Item 1</FullName>
                    </ItemRef>
                    <Quantity>1</Quantity>
                    <Rate>1100.00</Rate>
                </InvoiceLineMod>
            </InvoiceMod>
        </InvoiceModRq>
    </QBXMLMsgsRq>
</QBXML>

I am getting an error QuickBooks found an error when parsing the provided XML text stream.

please help

回答1:

If you refer to the QuickBooks OSR:

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

You'll notice that within the <InvoiceLineMod> element, this node is required:

  • <TxnLineID>

The OSR gives you a bit more information too:

TxnLineID

Identification number of the transaction line. (TxnLineID is supported as of v2.0 of the SDK. With qbXML v1.0 and v1.1, TxnLineID is always returned as zero.)

If you need to add a new transaction line in a transaction Mod request, you can do so by setting the TxnLineID to -1.

So, you'll need to add in a <TxnLineID> node. If it's a new line item, put -1 for the content within the node. If it's an existing line you're trying to update, put the TxnLineID value of the existing line in there.

Example:

...
<InvoiceLineMod>
    <TxnLineID>-1</TxnLineID>
    <ItemRef>
        <ListID>8000000A-1442469770</ListID>
        <FullName>Item 1</FullName>
    </ItemRef>
    <Quantity>1</Quantity>
    <Rate>1100.00</Rate>
</InvoiceLineMod>
...