This question has been flagged
3 Replies
34822 Views

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

 


Avatar
Discard
Author Best Answer

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}

Avatar
Discard
Best Answer

Hi, i need for odoo 11 with 

import xmlrpc.client


Avatar
Discard
Best Answer

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


Avatar
Discard