views:

332

answers:

3

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();
A: 

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

Broken Link
Hi RJ, This line: string post = XmlText.Text; reads the xml from a textbox. The above xml is in that textbox.-Jeff
Jeff Widmer
+1  A: 

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

Keith Palmer
The version number was part of the problem but also needed to include onError="continueOnError" in the QBXMLMsgsRq tag otherwise it would error out too. I am putting the full XML that worked in another answer.
Jeff Widmer
A: 

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>
Jeff Widmer