Skip to Content
Menu
This question has been flagged
2 Replies
12685 Views

The actual question is facing error in API integration odoo-v12 :

code:

import xmlrpc.client
import logging

url, db = 'localhost:8070', 'lab12'
username, password = 'admin', 'admin'
logging.info("url {} , db {}".format(url, db))
common = xmlrpc.client.ServerProxy('{}/xmlrpc.client/2/common'.format(url))
common.version()
Error:

raise OSError("unsupported XML-RPC protocol")
OSError: unsupported XML-RPC protocol

Any idea !!!! How to resolve the error.

Avatar
Discard
Best Answer

Hi Ramkumar,

Your endpoint configurations are wrong. In V11 & V12 they're no longer under /xmlrpc.client/2/common but under /xmlrpc/2/common
Here's a working example:

from xmlrpc import client as xmlrpclib
url = 'http://127.0.0.1:12000'
db = 'your_database'
username = 'admin'
password = 'admin'

common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

uid = common.login(db, username, password)
result = models.execute(db, uid, password, 'res.partner', 'search_read', [['id', '=', 1]])
number_of_customers = models.execute(db, uid, password, 'res.partner', 'search_count', [])
print('Number of customers: ' + str(number_of_customers))
print('result: ' + str(result[0].get('name')))


Regards,

Yenthe

Avatar
Discard
Author Best Answer

Thanks, It worked perfectly for v11 but for v12 it throws protocol error.

Error:

xmlrpc.client.ProtocolError: <ProtocolError for localhost:8071/xmlrpc/2/common: 404 NOT FOUND>
Avatar
Discard
Author

odoo-server-12.0-conf file needs a change the error resolved:

server_wide_modules = None

Related Posts Replies Views Activity
2
Feb 20
10264
1
Jul 19
3422
2
May 22
9415
2
Nov 19
3367
2
Jul 23
1859