コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
40367 ビュー

I am learning how to use XML RPC, however I am not even able to pass the basic connectivity test.

Any help is really welcomed:

# python
Python 2.7.3 (default, Jun 22 2015, 19:33:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlrpclib
>>> info = xmlrpclib.ServerProxy('http://localhost:8069').start()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1587, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1321, in single_request
response.msg,
xmlrpclib.ProtocolError: <ProtocolError for localhost:8069/RPC2: 404 NOT FOUND>
>>>


Regarding open ports:

# netstat -ta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost.localdom:8069 *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost.lo:postgresql *:* LISTEN
tcp6 0 0 [::]:https [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN

 


アバター
破棄
著作者 最善の回答

Already found the answer by rereading the docs:

# cat testrpc2.py
import xmlrpclib
url = 'http://localhost:8069'
db = 'mydb1'
username = 'admin'
password = 'xxxxxxxx'
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
output = common.version()
print output
# python testrpc2.py
{'server_version_info': [8, 0, 0, 'final', 0], 'server_serie': '8.0', 'server_version': '8.0-20150726', 'protocol_version': 1}

アバター
破棄
最善の回答

Hi, i need for odoo 11 with 

import xmlrpc.client


アバター
破棄
最善の回答

For Odoo 15 and Python version 3.8


import xmlrpc.client
url = "http://localhost:8069"

db = "mydatabase" #database name here

username = 'admin'

password = "admin"

common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))

ver= common.version()   

print(ver)
uid = common.authenticate(db, username, password, {})

print(uid) # Check access expected to print 2


アバター
破棄
関連投稿 返信 ビュー 活動
1
1月 23
2447
3
8月 20
5047
0
2月 18
2554
0
5月 16
7338
0
4月 16
4273