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.