xmlrpc icon indicating copy to clipboard operation
xmlrpc copied to clipboard

Error passing a XmlRpcStruct array as parameter

Open hayronruiz opened this issue 1 year ago • 0 comments

I'm trying to send a structure like this in a .NET6 class clibrary wrote on C#:

{ "e_key": "abc", "other_charge_line_ids": [ {"name": "test", "quantity": 1}, {"name": "test1", "quantity": 2} ] }

The code is as follow:

` XmlRpcStruct invoiceDict = new XmlRpcStruct(); invoiceDict.Add("e_key", account.accountKey);

if (account.OtherCharges.Any()) { var otherChargesArray = new XmlRpcStruct[account.OtherCharges.Count]; for (int i = 0; i < account.OtherCharges.Count; i++) { var otherCharge = account.OtherCharges[i]; otherChargesArray[i] = new XmlRpcStruct(); otherChargesArray[i].Add("name", otherCharge.otherchargesDescription); otherChargesArray[i].Add("quantity", otherCharge.quantity); } invoiceDict.Add("other_charge_line_ids", otherChargesArray); } else invoiceDict.Add("other_charge_line_ids", ""); `

And i'm getting the following error after call execute_kw:

CookComputing.XmlRpc.XmlRpcUnsupportedTypeException: A parameter is of, or contains an instance of, type System.Object[] which cannot be mapped to an XML-RPC type at CookComputing.XmlRpc.XmlRpcSerializer.SerializeRequest(Stream stm, XmlRpcRequest request) at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke(Object clientObj, MethodInfo mi, Object[] parameters) at XmlRpcProxyb101e61b-922b-4f52-a3b1-57abf64daa13.execute_kw(String db, Int32 uid, String password, String model, String methodName, Object args) at Skill4IT.ApiSuite.Odoo.OdooSync.Create(String db, Int32 uid, String password, String model, String method, XmlRpcStruct args) at Skill4IT.ApiSuite.Odoo.OdooSync.SynchronizeClosedAccounts(List`1 accounts, String model, String method)

The tricky point here is that the same code works fine using the original CookComputing library.

hayronruiz avatar Oct 05 '22 18:10 hayronruiz