用于发布到 QuickBooks Online Edition 的有效 XML - 接收 (400) 错误请求错误 [英] Valid XML for posting to QuickBooks Online Edition - Receiving (400) Bad Request Error

查看:40
本文介绍了用于发布到 QuickBooks Online Edition 的有效 XML - 接收 (400) 错误请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将以下 xml 发布到 https://apps.quickbooks.com/j/AppGateway 和我一直得到的是错误:远程服务器返回错误:(400)错误请求.有没有人知道我做错了什么?下面是我用来发布 xml 的 C# 代码.

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.

谢谢,-杰夫

更新:要向我的问题添加更多内容,我认为 (400) Bad Request 错误表明我的 xml 或我发布 xml 的方式存在严重错误.所以这就是我问这个问题的原因......我在这里错过了什么?

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

推荐答案

As Keith Palmer 在他的回答中提到版本号需要为 6.0,但还需要包含 QBXMLMsgsRq 标记的 onError 属性.(我也按照 Keith Palmer 的建议更正了时间格式.)

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.)

完整/有效的 xml 在这里:

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>

这篇关于用于发布到 QuickBooks Online Edition 的有效 XML - 接收 (400) 错误请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆