Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to request data to JSON-RPC using python

I want to dump some data from a website with JSON-RPC but i cant get any information. I'm using post request and even simulating headers using python but seems like isn't enough...

Im getting this error: {"error":{"code":590,"msg":"couldn't parse request arguments"}}

code:

#!/usr/bin/python
import urllib,urllib2,json,httplib

url = 'localhost'
parameters = {'method':'buscador.obtenerGruposAsignaturas',"params":json.dumps(["2025333","0"])}
data = urllib.urlencode(parameters)
headers = {
"Content-Type": "application/json",
'Content-Length' : len(data),
"Referer":"localhost",
"Cookie":'JSESSIONID=2C6BBA00328C1C2F67794E50337D6E3A.N1TS002'
"User-Agent":'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'}
conn=httplib.HTTPConnection(url,80)
conn.request("POST","/search/JSON-RPC",data,headers)



page = conn.getresponse().read()
print page

Thanks for comments or suggestions

like image 712
Motheus Avatar asked Oct 08 '22 16:10

Motheus


1 Answers

If you are using JSON-RPC, perhaps you should encode parameters in json and not urlencode?

like image 150
Dima Tisnek Avatar answered Oct 13 '22 09:10

Dima Tisnek