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

  • rhg
  • rhg's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #159297 by rhg
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'/

) 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.
  • rhg
  • rhg's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months 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.

Lime-years ahead

Online-surveys for every purse and purpose