Welcome to the LimeSurvey Community Forum

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

Problems with API

  • paochoa
  • paochoa's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
16 hours 39 minutes ago - 16 hours 37 minutes ago #267332 by paochoa
Problems with API was created by paochoa
Good morning, 
I have deployed LimeSurvey 6.6.5 in Docker on my own servers and I am having a problem when trying to export the responses of a survey via the API. I have created a simple Python script that obtains a session key and afterwards tries to export the responses of a specific survey (which is specified using its surveyID number). The method used for the latter task is export_responses. The problem is that as a result of the method execution I get the webpage in which all the API methods are explained, but I don't get the expected, a file contening the responses of the mentioned survey.
The code is as follows:
Code:
from limesurveyrc2api.limesurvey
import LimeSurvey
import requests
import sys
url = 'https://xxxxxxxxx/index.php/admin/remotecontrol'
user = "admin"
password = ********
sid = '345943'
def export_responses2(skey,sid):
    try:
        response = requests.get(url, \
                          params={"method":"export_responses","params":[skey,sid,"csv"], "id":1}, \
                          headers={'content-type': 'application/json', 'connection': 'Keep-Alive'})
        if response.status_code == 200:
            return response.content
    except :
        e = sys.exc_info()[0]
        print ( "Error: %s" % e )
api = LimeSurvey(url = url, username = user)
api.open(password = password)
skey = api.session_key
print(export_responses2(skey, sid))

Thanks in advance.
Last edit: 16 hours 37 minutes ago by paochoa.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
12 hours 40 minutes ago #267339 by DenisChenu
Replied by DenisChenu on topic Problems with API
Export responses in base64 encoded string

api.limesurvey.org/classes/remotecontrol...hod_export_responses

You must decode before using

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose