Skip to Content
Menu
This question has been flagged
5 Replies
8613 Views

Hi,

I follow the docs: https://www.odoo.com/documentation/14.0/webservices/odoo.html

I am trying to make a test connection to demo as shown in the example: $info = ripcord::client('https://demo.odoo.com/start')->start();

Everything goes well. I get the host, database, username, and password.

When I call $common->version(); I get the correct response.

But when trying to $uid = $common->authenticate($db, $username, $password, array()); I get the following error:

Traceback (most recent call last): File "/home/odoo/src/odoo/14.0/odoo/addons/base/controllers/rpc.py", line 69, in xmlrpc_2 response = self._xmlrpc(service) File "/home/odoo/src/odoo/14.0/odoo/addons/base/controllers/rpc.py", line 49, in _xmlrpc result = dispatch_rpc(service, method, params) File "/home/odoo/src/odoo/14.0/odoo/http.py", line 140, in dispatch_rpc result = dispatch(method, params) File "/home/odoo/src/odoo/14.0/odoo/service/common.py", line 56, in dispatch return g[exp_method_name](*params) File "/home/odoo/src/odoo/14.0/odoo/service/common.py", line 27, in exp_authenticate return res_users.authenticate(db, login, password, {**user_agent_env, 'interactive': False}) TypeError: 'list' object is not a mapping

What am I doing wrong?

Avatar
Discard
Author

Thank you, Piotr!

This is a correct answer:

$common = ripcord::client("$url/xmlrpc/2/common");

$version = $common->version();

$uid = $common->authenticate($db, $username, $password, $version);

Best Answer

Try to pass JSON as the last argument instead of an array.

$uid = $common->authenticate($db, $username, $password, {});


Avatar
Discard
Best Answer

I had the same situation. In my case working solution:

$common = ripcord::client("$url/xmlrpc/2/common");
$version = $common->version();
$uid = $common->authenticate($db, $username, $password, $version);

Please confirm, if this solution works to you.

Avatar
Discard
Author Best Answer

Thank you.

This will trigger PHP Parse error error: $uid = $common->authenticate($db, $username, $password, {});

I tried: $uid = $common->authenticate($db, $username, $password, "{}"); but it triggers similar error:

array(2) { ["faultCode"]=> int(1) ["faultString"]=> string(761) "Traceback (most recent call last): File "/home/odoo/src/odoo/14.0/odoo/addons/base/controllers/rpc.py", line 69, in xmlrpc_2 response = self._xmlrpc(service) File "/home/odoo/src/odoo/14.0/odoo/addons/base/controllers/rpc.py", line 49, in _xmlrpc result = dispatch_rpc(service, method, params) File "/home/odoo/src/odoo/14.0/odoo/http.py", line 140, in dispatch_rpc result = dispatch(method, params) File "/home/odoo/src/odoo/14.0/odoo/service/common.py", line 56, in dispatch return g[exp_method_name](*params) File "/home/odoo/src/odoo/14.0/odoo/service/common.py", line 27, in exp_authenticate return res_users.authenticate(db, login, password, {**user_agent_env, 'interactive': False}) TypeError: 'str' object is not a mapping " }
Any other thoughts?

Avatar
Discard
Best Answer

I tried: $uid = $common->authenticate($db, $username, $password, "{}"); but it triggers similar error:

With the quote around the "{}", you give a string instead of a dict.

 

Actually, python needs a dict to be present (the {}) and it can be empty.

A JSON string will not work.


That part of the code did change recently, making it impossible to give an empty array.

The workaround is to give a named array like this:

array("a"=>"b")


A pull request is in progress to allow an empty array parameter as before.

Avatar
Discard
Best Answer

I am resolved the problem passing in to last parameter the value returned in the method Version. I am programming at C# y the code is this:

OdooVersion vVersion = XmlRpcProxyGen.Create<OdooVersion>(); 
vVersion.Url = this._UrlBase + "/xmlrpc/2/common"; 
object vResult = vVersion.version();
OdooAutenticar proyCall = XmlRpcProxyGen.Create<OdooAutenticar>();
proyCall.Url = this._UrlBase + "/xmlrpc/2/common";
 int vResult2 = proyCall.authenticate(this._BaseDatos.Trim() , this._Usuario.Trim(), this._Password.Trim(), vResult); 
 return vResult2; 

The error only occurs the version 14.
In the version 12 or 13 the call "Authenticate" method runs without problems
Avatar
Discard
Related Posts Replies Views Activity
4
Aug 24
33248
0
Jan 24
1016
0
Jul 21
2184
0
Sep 24
3
0
Sep 24
344