observo observo - 3 months ago 17
PHP Question

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

I am using consobyte PHP SDK for QuickBooks Desktop and when I try to add Non Inventory Item, it throws the error-0x80040400: QuickBooks found an error when parsing the provided XML text stream.

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ItemNonInventoryAddRq requestID="38">
<ItemNonInventoryAdd>
<Name>46428</Name>
<SalesAndPurchase>
<SalesDesc>Apple Watch (not Sport)</SalesDesc>
<SalesPrice>50.00</SalesPrice>
<IncomeAccountRef>
<FullName>Merchandise Sales</FullName>
</IncomeAccountRef>
<PurchaseDesc>Apple Watch (not Sport)</PurchaseDesc>
<PurchaseDesc>50.00</PurchaseDesc>
<ExpenseAccountRef>
<FullName>Repairs and Maintenance</FullName>
</ExpenseAccountRef>
</SalesAndPurchase>
</ItemNonInventoryAdd>
</ItemNonInventoryAddRq>
</QBXMLMsgsRq>
</QBXML>

Answer

Fix this:

   <PurchaseDesc>Apple Watch (not Sport)</PurchaseDesc>
   <PurchaseDesc>50.00</PurchaseDesc>

Anytime you get this error message:

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

The first thing you should do is look at your XML closely. And then run it through the XML Validator tool included with the QuickBooks SDK. It tells you exactly what's wrong:

Line: 15
LinePos: 25
Src Text: <PurchaseDesc>50.00</PurchaseDesc>
Reason: Element content is invalid according to the DTD/Schema.
Expecting: PurchaseCost, PurchaseTaxCodeRef, ExpenseAccountRef, PrefVendorRef.