使用XML更新了问题。我之前用一个验证器检查过它,它通过了。这个问题可能是别的。再次感谢。Google Checkout/GAE:urlfetch:XML解析器错误。内容在序言中不允许
您能否让我知道下面的代码有什么问题?我正在使用它来提交服务器到服务器签出API请求。
我不断收到错误:“错误解析XML;从解析器的消息是:内容是不是在序言”允许
我已经尝试了所有的排列组合,同时还搜查网但。不能得到任何线索你及时的帮助会我坚持不胜感激
谢谢 .Ashish PS:以下base64encoded值用于验证下面的安全性被修改,因此只是一个随机值。
XML = "..."
form_fields = {'XML': XML}
form_data = urllib.urlencode(form_fields)
result = urlfetch.fetch(url='https://sandbox.google.com/checkout/api/checkout/v2/merchantCheckout/Merchant/MERCHANT_ID', payload= form_data,
method=urlfetch.POST,
headers={"Authorization": "Basic Kfgoijkef3fdgikneijerfererererwetfni43rfeferr=",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/xml;charset=UTF-8"
}
)
XML = "<?xml version='1.0' encoding='UTF-8'?> \
<checkout-shopping-cart xmlns='http://checkout.google.com/schema/2'> \
<shopping-cart> \
<items> \
<item> \
<item-name>HelloWorld 2GB MP3 Player</item-name> \
<item-description>HelloWorld, the simple MP3 player</item-description> \
<unit-price currency='USD'>159.99</unit-price> \
<quantity>1</quantity> \
</item> \
</items> \
</shopping-cart> \
<checkout-flow-support> \
<merchant-checkout-flow-support> \
<shipping-methods> \
<flat-rate-shipping name='SuperShip Ground'> \
<price currency='USD'>9.99</price> \
</flat-rate-shipping> \
</shipping-methods> \
</merchant-checkout-flow-support> \
</checkout-flow-support> \
</checkout-shopping-cart>"
听起来好像是没有很好地形成的XML。你是如何产生它的?寻找字符串开头附近的杂散字符。 – bobince
用我发送的XML更新。这早些时候通过了验证器。还有一些错误吗?再次感谢。 – user926385