Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

[SOLVED]Remotecontrol API aFields value

  • mi_for
  • mi_for's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #229365 by mi_for
Remotecontrol API aFields value was created by mi_for
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.3.18+220530
Own server or LimeSurvey hosting: Own server
Survey theme/template: Fruity
==================
Hi,

I am trying to export specific questions from a survey via the remote control API (in R with the limer package). As there has been no answer on the limer github page, I wanted to ask here for some guidance.
My issue is that regardless of wheter I call the the API with or without questions specified (parameter "$aFields"), it always returns the full survey data (please note that I could ofc just select the questions after the export directly in R, but I want to understand the API call and the issue here). I am also posting here b/c my problems could be related to the API/json and less to R/limer.

The following json call is sent to the API (ofc with a valid sessionkey): {"method":"export_responses","id":" ","params":{"sSessionKey":"<my_session_key>","iSurveyID":8698I53,"sDocumentType":"csv","sLanguageCode":{},"sCompletionStatus":"complete","sHeadingType":"code","sResponseType":"long","aFields":["869853X191X2006","869853X191X2009"]}}

Is there anything that looks wrong?

Cheers,
Michael
P.S. Interestingly, when I specify only one question in "aFields", only the last three characters of the whole base64 enc string are returned.

 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago #229369 by Joffm
Replied by Joffm on topic Remotecontrol API aFields value
Hi, Michael,

I do not see an issue using this
Code:
$surveyResponses = $myJSONRPCClient->export_responses(
    $sessionKey,
    $survey_id,
    'json', // Document type : pdf,csv,xls,doc,json
    null, // Language code : null : default from survey
    'complete', // Stautus complete|incomplete|all
    NULL, // Heading : code|full|abbreviated : question text, default code
    NULL, // answer : short|long , default : long
    1,    // From Response ID
    30,   // To Response ID
    ['id','token','submitdate','lastpage','interviewtime','159677X490time','159677X487time','159677X490X9219SQ001','159677X490X9221SQ001']
    );

Here shown as table


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: mi_for

Please Log in to join the conversation.

  • mi_for
  • mi_for's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #229401 by mi_for
Replied by mi_for on topic [SOLVED]Remotecontrol API aFields value
Thank you for sharing your code example. As always, it helped solving my issue.
The problem was that I did not specify "iFromResponseID" and "iToResponseID" (in my R call). Though being optional, it seems it is needed that the "aFields" argument is evaluated.
It works now.
Just out of curiosity: How do you get your questioncodes (e.g. "159677X490X9219SQ001")? I either inspect the questionnaire (and leave out the "java" part of the input ID or I combine survey ID, group ID, qid and answercode by looking them up in the question overview in the GUI. Is there a smarter way?

Best,
Michael

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose