0
0
0ralo2021-07-26 16:16:13
Python
0ralo, 2021-07-26 16:16:13

How to make an RPC request in python?

In short, there is a task. I need to make a request to the RPC server and get a json response, parse it, etc. I can't make this request in my python. I used requests lib and this one . Both return 401, although I provided authorization data. Can you tell me what I'm doing wrong?
Did it like this:

import requests
data={"rpsuser": ..., "prcpassword":..., "method": "method_name"}
requests.post("ip and port", json=data}

so
from jsonrpcclient import request
request("ip and port" , "method_name", rpsuser="...", prcpassword="...")

How do I login and execute the method "method_name"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0ralo, 2021-07-27
@0ralo

In short, I myself found the answer, the point is that authorization data is not sent to the body, but to the address.
So my request should have looked like this

import requests
requests.post("rpsuser:[email protected]:port", json={"method": method})

G
German Zuiakov, 2021-07-26
@HermanZuiakov

Google)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question