Remote Control API not working for python and node.js

More
1 month 2 weeks ago #159297 by rhg
rhg created the topic: Remote Control API not working for python and node.js
I am following manual.limesurvey.org/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.
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.

Please Log in to join the conversation.

More
1 month 2 weeks ago #159299 by rhg
rhg replied the topic: Remote Control API not working for python and node.js
I was able to solve this by replacing the format. It is not working for CSV but it is working for json and xls.
  req = urllib2.Request(url='https://DOMAIN/index.php/admin/remotecontrol',\
                          data='{\"method\":\"export_responses\",\"params\":[\"'+skey+'\",\"'+sid+'\",\"xls\",\"en\",\"full\"],\

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!