Skip to Content
Menu
This question has been flagged
1 Reply
4295 Views

I had use Java to interactive with api call_button.

When I use postman to Post this cURL, it is require only Id of Delivery Orders (1199)


curl --location --request POST 'https://stag-odoo.crosspanda.com/web/dataset/call_button' \

--header 'authority: stag-odoo.crosspanda.com' \

--header 'accept: application/json, text/javascript, */*; q=0.01' \

--header 'x-requested-with: XMLHttpRequest' \

--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' \

--header 'content-type: application/json' \

--header 'origin: https://stag-odoo.crosspanda.com' \

--header 'sec-fetch-site: same-origin' \

--header 'sec-fetch-mode: cors' \

--header 'sec-fetch-dest: empty' \

--header 'referer: https://stag-odoo.crosspanda.com/web?' \

--header 'accept-language: vi,en-US;q=0.9,en;q=0.8' \

--header 'cookie: _hjid=836b8983-c312-414e-b609-971656781304; __cfduid=ddc875cf512b6cd4bf6dcfdc00507f0b51602652130; session_id=823b706e981832b24aba25967980f4097548ef1f; _hjTLDTest=1; crisp-client%2Fsession%2Ff757cc9f-4cbf-4d61-80eb-425295250e4c=session_9a7ed057-9b7a-48c5-96a2-c1017fe4973e; session_id=823b706e981832b24aba25967980f4097548ef1f' \

--data-raw '{"jsonrpc":"2.0","method":"call","params":{"args":[[1199]],"method":"button_validate","model":"stock.picking"},"id":450789143}'

----------------------------------------------------------------------------------------

But when I use Java, it return this message


Traceback (most recent call last):

  File "/usr/lib/python3.5/xmlrpc/client.py", line 509, in __dump

    f = self.dispatch[type(value)]

KeyError: <class 'odoo.tools.misc.frozendict'>


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/base/controllers/rpc.py", line 69, in xmlrpc_2

    response = self._xmlrpc(service)

  File "/usr/lib/python3/dist-packages/odoo/addons/base/controllers/rpc.py", line 50, in _xmlrpc

    return dumps((result,), methodresponse=1, allow_none=False)

  File "/usr/lib/python3.5/xmlrpc/client.py", line 951, in dumps

    data = m.dumps(params)

  File "/usr/lib/python3.5/xmlrpc/client.py", line 501, in dumps

    dump(v, write)

  File "/usr/lib/python3.5/xmlrpc/client.py", line 523, in __dump

    f(self, value, write)

  File "/usr/lib/python3.5/xmlrpc/client.py", line 594, in dump_struct

    dump(v, write)

  File "/usr/lib/python3.5/xmlrpc/client.py", line 519, in __dump

    raise TypeError("cannot marshal %s objects" % type(value))

TypeError: cannot marshal <class 'odoo.tools.misc.frozendict'> objects


I think it is not my fail.

Please help me.

Thank you so much!

Avatar
Discard
Author Best Answer

client.doRequest("stock.picking", "button_validate", asList(asList(1199)), null);

client.doRequest("stock.immediate.transfer", "process", asList(asList(2579)), null);

Action 2 can run normally, but action 1 can not.

This is code of doRequest

public Object doRequest(String model, String method, List args, List<String> fields) throws XmlRpcException {

        XmlRpcClient models = new XmlRpcClient() {

            {

                setConfig(new XmlRpcClientConfigImpl() {{

                    try {

                        setServerURL(new URL(String.format("%s/xmlrpc/2/object", url)));

                    } catch (MalformedURLException e) {

                        e.printStackTrace();

                    }

                }});

            }

        };

        System.out.println(url);

        return models.execute("execute_kw", asList(database, uid, password, model, method, args, new HashMap() {{

            if (fields != null) {

                put("fields", fields);

            }

        }}));

    }



Avatar
Discard
Related Posts Replies Views Activity
1
Sep 23
859
0
Aug 22
1396
1
Dec 19
10539
2
Mar 18
5135
1
Mar 15
16643