Welcome to the LimeSurvey Community Forum

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

Adding a new response using the API's add_response method resulting to error

  • mikeictinus
  • mikeictinus's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #162378 by mikeictinus
Hello

I have a test survey with a single field which stores the name.

I am trying to use the api to add a new response with the name "john doe" but I keep getting errors.

Here is the code:


<?php

$aResponseData = array(
"Q1" => "John Doe"
)

$groups = $jsonRPC->add_response($sessionKey, $survey_id, $aResponseData);
?>


This is the error

PHP Fatal error: Uncaught Error: Call to a member function add_response() on null


The screenshot contains the column names

Can anyone please help? Does anyone know what is the format of the aResponseData? I was able to use the export_responses method and it worked. It is just that I am not able to get the add_response to work.

Thank you
Mike
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #162384 by tpartner
I believe you need to use the question ID for Q1, not the question code.

(the question ID will be the column name in the DB)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose