Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong key in list_surveys() request #17

Open
maxpejs opened this issue Feb 22, 2024 · 1 comment
Open

Wrong key in list_surveys() request #17

maxpejs opened this issue Feb 22, 2024 · 1 comment

Comments

@maxpejs
Copy link

maxpejs commented Feb 22, 2024

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

@felixdollack
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants