Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Remote Control API not working for python and node.js

More
9 years 4 weeks ago #159297 by rhg
I am following www.limesurvey.org/manual/RemoteControl_2_API and the official documentation of the API and trying to use export responses method by using Node.js and Python code. I am able to get my session key by get_session_key method, however when I am calling export_response method I am getting some sort of exception(' No JSON object could be decoded'/ <type 'exceptions.ValueError'></p>) in python.
Code:
def export_responses2(skey,sid): req = urllib2.Request(url='https://DOMAIN/index.php/admin/remotecontrol',\ data='{\"method\":\"export_responses\",\"params\":[\"'+skey+'\",\"'+sid+'\",\"csv\",\"en\",\"full\"],\ "id\": 1}') req.add_header('content-type', 'application/json') req.add_header('connection', 'Keep-Alive') try: f = urllib2.urlopen(req) myretun = f.read() j=json.loads(myretun) print j return j['result'] except : e = sys.exc_info()[0] print ( "<p>Error: %s</p>" % e )


I have enabled JSON RPC under my interfaces section of global settings.
The topic has been locked.
More
9 years 4 weeks ago #159299 by rhg
I was able to solve this by replacing the format. It is not working for CSV but it is working for json and xls.
Code:
req = urllib2.Request(url='https://DOMAIN/index.php/admin/remotecontrol',\ data='{\"method\":\"export_responses\",\"params\":[\"'+skey+'\",\"'+sid+'\",\"xls\",\"en\",\"full\"],\
The topic has been locked.
Moderators: holch, tpartner

Lime-years ahead

Online-surveys for every purse and purpose