Valid XML for posting to QuickBooks Online Edition

2019-08-18 06:26发布

I am trying to post the below xml to https://apps.quickbooks.com/j/AppGateway and all I keep getting is the error: The remote server returned an error: (400) Bad Request. Does anyone have any ideas what I am doing wrong? See below for the C# code that I am using to post the xml.

Thanks, -Jeff

UPDATE: To add more to my question, I am thinking that the (400) Bad Request error is indicating that I have something grossly wrong with the xml or with the way I am posting the xml. So that is why I am asking this question... what am I missing here?

<?xml version="1.0" encoding="utf-8" ?>
<?qbxml version="7.0"?>
<QBXML>
<SignonMsgsRq>
<SignonDesktopRq>
<ClientDateTime>7/20/2009 12:36PM</ClientDateTime>
<ApplicationLogin>APP_LOGIN</ApplicationLogin>
<ConnectionTicket>CONNECTION_TICKET</ConnectionTicket>
<Language>English</Language>
<AppID>APP_ID</AppID>
<AppVer>1</AppVer>
</SignonDesktopRq>
</SignonMsgsRq>
<QBXMLMsgsRq>
<CustomerQueryRq requestID="2" />
</QBXMLMsgsRq>
</QBXML>



WebRequestObject = (HttpWebRequest)WebRequest.Create(requestUrl);
WebRequestObject.Method = "POST";
WebRequestObject.ContentType = "application/x-qbxml";
WebRequestObject.AllowAutoRedirect = false;
string post = XmlText.Text;

WebRequestObject.ContentLength = post.Length;

swr = new StreamWriter(WebRequestObject.GetRequestStream());
swr.Write(post);
swr.Close();

WebResponseObject = (HttpWebResponse)WebRequestObject.GetResponse();

4条回答
在下西门庆
2楼-- · 2019-08-18 06:33

As Keith Palmer mentioned in his answer the version number needs to be 6.0 but also need to include the onError attribute of the QBXMLMsgsRq tag. (I also corrected the time format too as recommend by Keith Palmer.)

Complete/working xml is here:

<?xml version="1.0" encoding="utf-8" ?> 
<?qbxml version="6.0"?> 
<QBXML> 
    <SignonMsgsRq>
        <SignonDesktopRq> 
            <ClientDateTime>2009-07-21T10:10:00</ClientDateTime> 
            <ApplicationLogin>APPLICATION_LOGIN</ApplicationLogin>
            <ConnectionTicket>CONNECTION_TICKET</ConnectionTicket>
            <Language>English</Language> 
            <AppID>APP_ID</AppID>
            <AppVer>1</AppVer> 
        </SignonDesktopRq> 
    </SignonMsgsRq> 
    <QBXMLMsgsRq onError="continueOnError"> 
        <CustomerQueryRq requestID="2" /> 
    </QBXMLMsgsRq> 
</QBXML>
查看更多
Ridiculous、
3楼-- · 2019-08-18 06:43

You can get the XML for a customer query at this site:

QuickBooks Online OSR

Select CustomerQuery as the message. Use Chrome because it doesn't work in all browsers. Click XmlOps and you'll see the XML.

On another note, I have a commercial solution available here:

QuickBooks Online C# Development Integration

查看更多
Deceive 欺骗
4楼-- · 2019-08-18 06:48

Change your qbXML version to 6.0, QuickBooks Online Edition doesn't support 7.0 yet.

查看更多
神经病院院长
5楼-- · 2019-08-18 06:48

where is the xml posted in request?? Or you are missing to paste some code here. I don't see the request has XML in the above code. The request is bad because the request contain no XML. At least from what I see above

查看更多
登录 后发表回答