How to fix faultCode not int or string error on odooWrapper

Viewed 353

Guys Plz help me I have to intersect my C# application with Odoo, and can now connect to Odoo database, put values on it, update values using OdooRpcWrapper ( link of wrapper: https://github.com/iceship/OdooRpcWrapper) but I'm blocked now when I try to fetch model data from Odoo an error display

'CookComputing.XmlRpc.XmlRpcInvalidXmlRpcException' occurred in CookComputing.XmlRpcV2.dll faultCode not int or string

I found that when I used an empty filter it works (ofc when the empty object returns) soo I guess that the problem in data receiving. So guys plz help me I need it so much.

My code:

            //Define what model you want to use
            OdooModel productModel = api.GetModel("product.template");
            object[] filter = new object[1];

            filter[0] = new object[3] { "name", "Dush", "" };
            List<OdooRecord> records = productModel.Search(filter);
            foreach (OdooRecord record in records)
            {
                MessageBox.Show(String.Format("[{0}] {1}", record.GetValue("default_code"), 
                record.GetValue("name")));
            }

Plugin side(odooAPI):

        public int Create(string model, XmlRpcStruct fieldValues)
        {
            return _objectRpc.create(_credentials.DbName, _credentials.UserId, _credentials.DbPassword, model, "create", fieldValues);
        }

        public int[] Search(string model, object[] filter)
        {
            return _objectRpc.search(_credentials.DbName, _credentials.UserId, _credentials.DbPassword, model, "search", filter);//Instruction of error
        }

        public bool Write(string model, int[] ids, XmlRpcStruct fieldValues)
        {
            return _objectRpc.write(_credentials.DbName, _credentials.UserId, _credentials.DbPassword, model, "write", ids, fieldValues);
        }

        public bool Remove(string model, int[] ids)
        {
            return _objectRpc.unlink(_credentials.DbName, _credentials.UserId, _credentials.DbPassword, model, "unlink", ids);
        }
1 Answers

It seems that your filter is not correctly written.
Try this:

object[] filter = new object[] { new object[] { "name", "=", "Dush"} };
Related