简体   繁体   中英

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. I am using XMLRPC for this purpose.

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

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.

Exception is at class XMLRPCClient, at line

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. But when I follow same procedure from Android I get Exception described above.
What should I do?

I also got same problem. I bypassed XMLRPC for last call and written php script to place order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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