简体   繁体   English

Magento API cart_coupon.add不起作用

[英]Magento api cart_coupon.add does not work

I am creating Android app that allows user to add product into his shopping cart and places order. 我正在创建一个Android应用,该应用允许用户将产品添加到他的购物车中并下订单。 I am using XMLRPC for this purpose. 我为此使用XMLRPC。

Following steps I have done 按照我已完成的步骤

1.cart.create
2.cart_customer.set
3.cart_customer.addresses
4.cart_shipping.list
5.cart_shipping.method
6.cart_product.add
7.cart_payment.list
8.cart_payment.method

All code works fine till cart_payment.method , but when I call cart_coupon.add api I get exception 直到cart_payment.method,所有代码都可以正常工作,但是当我调用cart_coupon.add api时出现异常

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {null}methodResponse
(position:START_TAG (empty) <br>@1:7 in java.io.InputStreamReader@4151b450) 
at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)

My code is: 我的代码是:

client = new XMLRPCClient(url);
object = client.callEx("call", new Object[]{sessionId,
                    "cart_coupon.add",new Object[]{shoppingCardId,couponcode}});

where url is valid magento host url,shoppingCardId is CardId that I get from server. 其中url是有效的magento主机url,shoppingCardId是我从服务器获取的CardId。

Exception is at class XMLRPCClient, at line 在行的XMLRPCClient类中发生异常

pullParser.require(XmlPullParser.START_TAG, null, Tag.METHOD_RESPONSE);

I think server replies with blank string and parser doesn't find start tag. 我认为服务器用空白字符串答复,并且解析器找不到开始标签。

If I call same api through php script, cart_coupon.add and cart.order work fine and I get order id in response and at server side in sales->orders , I can see order has been placed successfully. 如果我通过php脚本调用相同的api,则cart_coupon.add和cart.order正常工作,我得到了订单ID作为响应,并且在sales-> orders的服务器端,可以看到订单已成功放置。 But when I follow same procedure from Android I get Exception described above. 但是,当我从Android执行相同的过程时,出现上述异常。
What should I do? 我该怎么办?

I also got same problem. 我也遇到同样的问题。 I bypassed XMLRPC for last call and written php script to place order. 我绕过XMLRPC进行了最后一次呼叫,并编写了php脚本来下订单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM