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

i want to create API's but from where and how i can install xmlrpc in my ubuntu 20.04 and windows 10 machines.
please, please, give the exact download link which should not confuse for which one i have to download and use.

i created below python file test_api.py and executed but it is showing error.

---------------------------------------------
import xmlrpc.client

url = "127.0.0.1:8016"
db = "odoo16db"
username = "admin"
password = "admin"

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

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

if uid:
  print('authenticated')
else:
  print('cannot authenticate')
----------------------------------------------

run in terminal:  python3 test_api.py 

the error:
---------
Traceback (most recent call last):
File "text_api.py", line 9, in
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
File "/usr/lib/python3.8/xmlrpc/client.py", line 1419, in __init__
raise OSError("unsupported XML-RPC protocol")
OSError: unsupported XML-RPC protocol

please help.
regards

Avatar
Discard
Best Answer

Install the required packages by running the following command:

sudo apt-get install python3-xmlrpc

  1. Download the Python for Windows installer from the official Python website: https://www.python.org/downloads/windows/
  2. Run the installer and follow the installation instructions. Make sure to select the option to add Python to the system PATH during the installation process.
  3. Open a command prompt or PowerShell window.
  4. Install the required packages by running the following command:

pip install xmlrpc.client
Once you have installed the necessary packages, you can proceed with running your Python script. However, there is an issue with the URL format in your code that causes the "unsupported XML-RPC protocol" error.

Update the URL line in your test_api.py script to include the "http://" or "https://" prefix, like this:

url = "http://127.0.0.1:8016"
or

url = "https://127.0.0.1:8016"

After making this change, save the script and try running it again. The error should be resolved, and you should be able to authenticate using XML-RPC.

Please note that you might need to adjust the URL, database name, username, and password in your code to match your Odoo setup.

Avatar
Discard
Author

@shubham shiroya thank you for your help. after seeing your reply, i checked on my ubuntu machine, added http:// in start of variable's value 127.0.0.1 and it is working fine now.
thanks for your help.
regards

Related Posts Replies Views Activity
1
May 25
1249
1
Apr 25
2567
1
Apr 25
3314
1
Apr 25
921
4
Mar 25
5618