QBOv3 XML Validation Fault

痞子三分冷 提交于 2019-12-11 03:47:59

问题


I'm trying to send a couple of quickbooks queries together in a batch request. I've followed the formatting that Intuit gives here https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/00700_batch_operation but I keep getting a ValidationFault. I'm not sure what's causing the error, so any help would be greatly appreciated. Thanks!

XML:

<IntuitBatchRequest xmlns="http://schema.intuit.com/finance/v3">
    <BatchItemRequest bId="1"  >
        <Query query="Select * from Payment WHERE CustomerRef = '1933' ORDERBY TxnDate DESC MAXRESULTS 1"/>
    </BatchItemRequest>
    <BatchItemRequest bId="2"  >
        <Query query="Select * from Payment WHERE CustomerRef = '290' ORDERBY TxnDate DESC MAXRESULTS 1"/>
    </BatchItemRequest>
</IntuitBatchRequest>

Response I get back:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-02-07T12:47:32.442-08:00">
    <BatchItemResponse bId="1">
        <Fault type="ValidationFault">
            <Error code="4000">
                <Message>Error parsing query</Message>
                <Detail>QueryParserError: Encountered &quot;&lt;EOF&gt;&quot; at line 0, column 0. Was expecting: &quot;select&quot; ...
                </Detail>
            </Error>
        </Fault>
    </BatchItemResponse>
    <BatchItemResponse bId="2">
        <Fault type="ValidationFault">
            <Error code="4000">
                <Message>Error parsing query</Message>
                <Detail>QueryParserError: Encountered &quot;&lt;EOF&gt;&quot; at line 0, column 0. Was expecting: &quot;select&quot; ...
                </Detail>
            </Error>
        </Fault>
    </BatchItemResponse>
</IntuitResponse>

回答1:


It turns out Intuit's documentation is incorrect (at least for its QBOv3 REST API).

At https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/00700_batch_operation Intuit says the XML should be formatted in the way I showed in my first post, but it should actually be formatted like so:

<IntuitBatchRequest xmlns="http://schema.intuit.com/finance/v3">
    <BatchItemRequest bId="1">
        <Query>
            Select * from Payment WHERE CustomerRef = '1933' ORDERBY TxnDate DESC MAXRESULTS 1
        </Query>
    </BatchItemRequest>
    <BatchItemRequest bId="2">
        <Query>
            Select * from Payment WHERE CustomerRef = '290' ORDERBY TxnDate DESC MAXRESULTS 1
        </Query>
    </BatchItemRequest>
</IntuitBatchRequest>

I hope this helps others in the future! Thanks for all of the replies, they helped to narrow down the issue.




回答2:


Your query should look like

SELECT * from Payment WHERE

NOT

query * from Payment WHERE




回答3:


The CustomerRef is actually an entity of ReferenceType and you are sending the value for it. Try CustomerRef.value = "123"



来源:https://stackoverflow.com/questions/21638115/qbov3-xml-validation-fault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!