Hi @mco-system,
I propose to you a solution to communicate from a Python program to xo-server api.
import json
import aiohttp
import asyncio
from jsonrpc_websocket import Server
async def routine():
async with aiohttp.ClientSession() as client:
server = Server('ws://XO_SERVER_IP/api/', client)
await server.ws_connect()
# No signIn required
methodsInfoResult = await server.system.getMethodsInfo()
print('\n'.join([str(e) for e in methodsInfoResult.keys()]))
# signIn required
result = await server.session.signIn(username='YOUR_LOGIN', password='YOUR_PASSWORD') # email attribute is working in place of username
result = await server.xo.getAllObjects(filter={"type": "VIF"}, limit=10)
print('[')
print(', \n'.join([str(json.dumps(e, indent=4)) for e in result.values()]))
print(']')
asyncio.get_event_loop().run_until_complete(routine())
This code is using the jsonrpc_websocket library.
A full description is available on my blog => https://mickael-baron.fr/blog/2021/05/28/xo-server-websocket-jsonrcp (in french). A Java version is also available.