Welcome to the LimeSurvey Community Forum

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

Adding a response using the lime survey API

  • Kabengwa
  • Kabengwa's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 2 months ago - 6 years 2 months ago #164420 by Kabengwa
Hello,

I have been reading material all over the internet and trying to understand the Api that is provided here. how ever i am stack ... i have read the solutions offered by the users here and overflow but adding a response to a survey is playing me.
Code:
$answers_to_survey = array(
    "75195X10X117" => "A1",
    "75195X10X118" => "A1",
    "75195X11X119" => "A2",
    "75195X11X120" => "Y",
    "75195X11X121" => "Y",
    "75195X12X122" => "A1",
    "75195X12X123" => "Y",
    "75195X12X124" => "N",
    "75195X12X125" => "A2",
    "75195X13X126" => "A4",
    "75195X13X127" => "A2",
    "75195X13X128" => "N",
    "75195X13X129SQ001" => "Y",
    "75195X13X129SQ002" => "Sales",
    "75195X14X130" => "Y",
    "75195X14X131" => "N"
    );
    //adding the response to the survey
    $respond_to_survey = $myJSONRPCClient->add_response( $sessionKey, $survey_id, $answers_to_survey);
    echo '<pre>'; print_r($respond_to_survey); echo '<pre/>';
this is the little piece of php that i am trying to use to send some sort of response to the survey so that i can expand it further.

however its able to echo the number for the response but when i check in the response table there is nothing entered. am i doing something wrong?
Code:
 
"75195X10X117" => "Once a year [A1]",
"75195X10X118" => "Less than 24 hours [A1]",
"75195X11X119" => "Satisfactory [A2]",
"75195X11X120" => "Yes [Y]",
"75195X11X121" => "Yes [Y]",
"75195X12X122" => "1-5 Minutes [A1]",
"75195X12X123" => "Yes [Y]",
"75195X12X124" => "No [N]",
"75195X12X125" => "5-10 Times [A2]",
"75195X13X127" => "Satisfactory [A2]",
"75195X13X128" => "Just Okay [A3]",
"75195X13X129SQ001" => "Yes [Y]",
"75195X13X129SQ002" => "Sales",
"75195X14X130" => "Yes [Y]",
"75195X14X131" => "No [N]"
 
i also tried that format and it did not work.

I am using Version 2.72.3+171020 of limesurvey.

Let me attach some pictures for clarity.

Any help is welcome.




Last edit: 6 years 2 months ago by Kabengwa.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #164512 by tpartner
Replied by tpartner on topic Adding a response using the lime survey API
Your first example is correct.

I am at a loss as to why it doesn't work - I have tested it successfully in versions 2.73.0 and 3.4.1.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Kabengwa
  • Kabengwa's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #165606 by Kabengwa
Replied by Kabengwa on topic Adding a response using the lime survey API
I found what my problem was after u told me that my syntax was right. i was linking to the wrong database:unsure: ;) .... sorry had forgotte,n to update.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose