Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send array type #9

Closed
n454149301 opened this issue Mar 16, 2021 · 1 comment
Closed

Unable to send array type #9

n454149301 opened this issue Mar 16, 2021 · 1 comment

Comments

@n454149301
Copy link

n454149301 commented Mar 16, 2021

test.py:

I want send this:

{"jsonrpc": "2.0", "method": "Api.Login", "params": [{"username": "aaa", "authority": "saaa", "password": "paaa"}]

this is my code:

`

import asyncio
from jsonrpc_websocket import Server

async def routine():
    server = Server('wss://system_monitor_casbin:8808/cas/api/ws-jsonrpc/v1', verify_ssl=False)
    try:
        await server.ws_connect()
        # output: {"jsonrpc": "2.0", "method": "Api.Login", "params": {"username": "aaa", "authority": "saaa", "password": "paaa"}}
        await server.Api.Login({'username':"aaa", 'authority':'saaa', 'password':'paaa'})
        # output: {"jsonrpc": "2.0", "method": "Api.Login", "params": [[{"username": "aaa", "authority": "saaa", "password": "paaa"}]]}
        await server.Api.Login([{'username':"aaa", 'authority':'saaa', 'password':'paaa'}])

        # simple test
        # output: {"jsonrpc": "2.0", "method": "Api.Login", "params": [1]}
        await server.Api.Login(1)
        # output: {"jsonrpc": "2.0", "method": "Api.Login", "params": [[1]]}
        await server.Api.Login([1])
    finally:
        await server.close()
asyncio.get_event_loop().run_until_complete(routine())

`

@emlove
Copy link
Owner

emlove commented Mar 17, 2021

Looks like this was a legacy bug from jsonrpc-requests. Thanks for the report! I pushed out a new version jsonrpc-websocket==3.0.0 that should fix this bug. Your first example should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants