remote controle API- import_survey and set_survey_properties issues

More
1 year 4 months ago #137030 by fjannin
fjannin created the topic: remote controle API- import_survey and set_survey_properties issues
Hello,

I am building an app for generating dynamically a few dozen of surveys.
I intend to use XML file as templates, modify them and use Remote API to generate them.

I have exported a survey as lss file, and I try to import it with Remote Api, but it fails :
- even I got "Error: Invalid LimeSurvey survey structure XML"
- even I have no error with a null result and no import:
import_survey entity result : null
import_survey status : HTTP/1.1 200 OK

I thinks it may be related to encoding, these results differ by the way I encode inputData.

Here is my request :
requestLine : {"method": "import_survey", "params": {"sSessionKey ": "36sgszik8i8mftd9p2rqcnu8gkd5hyry", "sImportData ": [content of the xml exported file]} requestLine : {"method": "import_survey", "params": {"sSessionKey ": "36sgszik8i8mftd9p2rqcnu8gkd5hyry", "sImportData ": "", "sImportDataType ": "lss", "sNewSurveyName ": "imported1", "DestSurveyID ": "999999" }, "id": 1}
2016-05-30 10:39:00,911 [main] DEBUG org.inpt.surveyval.services.LimeSurveyHelper - content type : Content-Type: text/javascript
2016-05-30 10:39:00,911 [main] DEBUG org.inpt.surveyval.services.LimeSurveyHelper - import_survey entity result : {"status":"Error: Ce n'est pas un fichier valide de structure de questionnaire LimeSurvey."}

On the other hand, I have to set survey properties by API, for no happier result, with a null result :
requestLine : {"method": "set_survey_properties", "params": {"sSessionKey ": "qp68j52gzi8sirtuv2d8uzyt6ppw5fzv", "iSurveyID ": "999999", "aSurveyData ": {"description":"Structure de ce questionnaire","welcometext":"my welcome text ","endtext":"my end text"} }, "id": 1}
2016-05-30 13:34:24,275 [main] DEBUG org.inpt.surveyval.services.LimeSurveyHelper - setSurveyProperties result : null

Anybody has an idea ?

Please Log in to join the conversation.

More
1 year 4 months ago #137069 by DenisChenu
DenisChenu replied the topic: remote controle API- import_survey and set_survey_properties issues
Did you try with a clean .lss file no updated ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 4 months ago #137100 by fjannin
fjannin replied the topic: remote controle API- import_survey and set_survey_properties issues
Yes, i tried with an unmodified XML export from admin interface. It is an empty survey, but I can import it with success through admin interface.
Thanks

Please Log in to join the conversation.

More
1 year 4 months ago #137113 by DenisChenu
DenisChenu replied the topic: remote controle API- import_survey and set_survey_properties issues
And your updated lss file : can you import via admin GUI ?

Maybe an issue here ....

But hard to fix ..... go step by step .....

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #137141 by fjannin
fjannin replied the topic: remote controle API- import_survey and set_survey_properties issues
Yes, I can import all updated export files, but with remote API, I have only managed to import groups of questions ( import_group ).
For the other issue, about set_survey_properties, I have resolved it : I was using wrong method, it was set_language_properties for all message related settings of the survey. Though it is not mentioned straightforward in the API documentation, in the samples availables some field relative to each methods are mentioned.
Last Edit: 1 year 4 months ago by fjannin. Reason: unfinished sentence

Please Log in to join the conversation.

More
1 year 4 months ago #137146 by DenisChenu
DenisChenu replied the topic: remote controle API- import_survey and set_survey_properties issues
Hi,

Ok : my question is just to see if there are a bug in remote_control : then if
- You can import a lss file via admin GUI
- The same file isn't imported via a working remote_control system

I think it can be abug in LimeSurvey, then must be reported.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 4 months ago #137148 by fjannin
fjannin replied the topic: remote controle API- import_survey and set_survey_properties issues
Hi,

If it is a bug, it is more about the lack of information with the "null" result in HTTP 200 response.
Before to report a bug, I have to test again to fix conditions where it occurs.
In some case, I had success in importing a whole LSS survey export, several month ago, but it was not an empty Survey, it had groups of questions.
The tricky point about using these remote methods importing XML contents, is about encoding the importData field, it is very tedious.
My context is making it difficult :
- using Java as remote client : not the same API for encoding String as in PHP.
- having locale fr_FR on both development desktop and servers
- all this result in something hard to determine : what encoding to use when reading from file and writing to JSON serialisation.
For example, to get a import_group call working, I had to manage these steps :

InputXML = Normalizer.normalize(InputXML, Normalizer.Form.NFD);
InputXML = InputXML.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
encoded = Base64.encode( InputXML.getBytes("CP1252"));

Please Log in to join the conversation.

More
1 year 2 months ago #140867 by Moradzadeh
Moradzadeh replied the topic: remote controle API- import_survey and set_survey_properties issues
Hello, has this been resolved for you?

I am building a PHP file importer and am getting Status:Error. Just starting the debug process here, but if there's some information that can help short-circuit the effort, I'd appreciate it.

Michael

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now