Getting id through api
This message was also posted on Gitter: Hello Syspassians, I am coming here because of a little problem I am encountering while trying to search for an account through the API using JSON requests through a python script. I am using the demo of syspass for this test. I've already written a little code however I can't seem to get anything I should've gotten:
import json
import requests
search_acc_token = 'bce8541087e32d85bfb20a6421149613790b0760bb0ae61f79c33eddd6f0c47f '
s2 = 'c84a36f2ef577eeb58a771c17377f197c45429d540edefeead9f2a5b71668e6c '
demo_url = 'https://demo.syspass.org/api.php'
#headers = {'content-type': 'application/json','method': 'getAccountSearch'}
acc_search ={
'authToken': search_acc_token,
'text': 'Dev royalty SFTP'
}
#acc_search = json.dumps(acc_search)
acc_info = requests.post(demo_url, json= acc_search)
res = acc_info.json()
print(res)
I get this as an output:
{'jsonrpc': '2.0', 'error': {'code': -32600, 'message': 'Wrong format', 'data': ''}, 'id': None}
As you can see it doesn't finds it, I see that there are two accounts tabs on the demo somehow... but that's another subject. Any idea what could cause it or what I could be missing? Thank you for your reading and potential answer on the matter.
I worked my way through it, I just needed to specify jsonrpc version, the method and an id in the payload. Before closing this issue, if anyone could give me details as to why an id for the request?
Hello,
Please take a look to this gist https://gist.github.com/62338b33178544894cd7237c7fe170bd
The JSON-RPC id is not needed by the application, but it would be useful when several requests are being sent, since the client needs to know the id which the server is replying to.
Regards
Thank you for your answer, we managed our way through this one.
I worked my way through it, I just needed to specify jsonrpc version, the method and an id in the payload. Before closing this issue, if anyone could give me details as to why an id for the request?
Hey, can you show where did you add the jsonrpc version, the method and an id? I'm having the same problem :/