lindsay-stevens / limesurveyrc2api

LimeSurvey RC2 REST webservices client
MIT License
27 stars 34 forks source link

Poblem importing surveys #11

Closed Flipecs closed 1 year ago

Flipecs commented 5 years ago

Well I was trying to import surveys using .txt files and I had a huge problem, it broke lime.

After a while I tought I should share my solution. Well the problem is when you import a survey file it needs to be base64 encoded, and then python writes on the data to send to the server "b'yourEncodedText'", instead of "yourEncodedText". Also survey id and survey title are not mandatory arguments while in the api code it is. So I made this changes in the function import_survey:

def import_survey(self, idata, title=None, sid=None, type='lss'): data = """{ "id": 1, "method": "import_survey", "params": { "sSessionKey": "%s", "sImportData": "%s", "sImportDataType": "%s", "sNewSurveyName": "%s", "DestSurveyID": %s } }""" \ % (self.session_key, idata.decode('utf-8'), type, title if title else '', str(sid) if sid else '""') return self._getJSON(data)['result']

lindsay-stevens commented 1 year ago

Thanks but there's no import_survey in this repo, I guess you meant this for one of the forks?