limesurveyrc2api
limesurveyrc2api copied to clipboard
Wrong key in list_surveys() request
method _Survey.list_surveys() uses key 'iSurveyID' to get survey list. According to REST-API, it shoud be 'sUsername'
Tested with: limesurveyrc2ap master-commit: 866cf62 LimeSurvey Community Edition Version 6.4.7
Workaround is to overwrite the function.
def list_surveys(api, username=None):
from collections import OrderedDict
method = "list_surveys"
params = OrderedDict([
("sSessionKey", api.session_key),
("sUsername", username or api.username)
])
response = api.query(method=method, params=params)
response_type = type(response)
if response_type is dict and "status" in response:
status = response["status"]
error_messages = [
"Invalid user",
"No surveys found",
"Invalid session key"
]
for message in error_messages:
if status == message:
raise LimeSurveyError(method, status)
else:
assert response_type is list
return response
api.survey.list_surveys = list_surveys
# from the example
result = api.survey.list_surveys(api)