Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3062 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Autor

@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

Publicaciones relacionadas Respuestas Vistas Actividad
1
may 25
1401
1
abr 25
2661
1
abr 25
3445
1
abr 25
1030
4
mar 25
5807