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

Hello,

I am using follwoing code in a python script to connect to my Odoo server then give error


>>> import xmlrpclib

>>> host = "http://localhost:8069"

>>> db = "Db1"

>>> username = "nirali-acespritech"

>>> password = "123456"

>>> url = 'http://%s/xmlrpc/' % (host)

>>> common_proxy = xmlrpclib.ServerProxy(url+'common')

>>> object_proxy = xmlrpclib.ServerProxy(url+'object')

>>> uid = common_proxy.login(db,username,password)

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__

return self.__send(self.__name, args)

File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request

verbose=self.__verbose

File "/usr/lib/python2.7/xmlrpclib.py", line 1283, in request

return self.single_request(host, handler, request_body, verbose)

File "/usr/lib/python2.7/xmlrpclib.py", line 1311, in single_request

self.send_content(h, request_body)

File "/usr/lib/python2.7/xmlrpclib.py", line 1459, in send_content

connection.endheaders(request_body)

File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders

self._send_output(message_body)

File "/usr/lib/python2.7/httplib.py", line 897, in _send_output

self.send(msg)

File "/usr/lib/python2.7/httplib.py", line 859, in send

self.connect()

File "/usr/lib/python2.7/httplib.py", line 836, in connect

self.timeout, self.source_address)

File "/usr/lib/python2.7/socket.py", line 557, in create_connection

for res in getaddrinfo(host, port, 0, SOCK_STREAM):

socket.gaierror: [Errno -2] Name or service not known


please help me




Avatar
Discard
Best Answer

Hello,

There are some minor changes in you code.

>>> host = "http://localhost:8069"
.......
>>> url = 'http://%s/xmlrpc/' % (host)

If you print the url, it will be like: 'http://http://localhost:8069/xmlrpc/'

So just remove extra 'http://' from host or url.

Regards,

Avatar
Discard