remotecontrol not working: uncaught exception

More
3 years 8 months ago #126317 by tvanover
Hi,

I've followed the guidelines to enable json rpc here:

manual.limesurvey.org/RemoteControl_2_API#add_participants

I created the php example file:

<?php

// without composer this line can be used
// require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
include_once 'vendor/autoload.php';

define( 'LS_BASEURL', ' xxx.be/limesurvey/ '); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'xxxxxx' );

// the survey to process
$survey_id=425522;

// instanciate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );

// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );

// receive all ids and info of groups belonging to a given survey
$groups = $myJSONRPCClient->list_groups( $sessionKey, $survey_id );
print_r($groups, null );

// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );

?>

But when I try to test it, I get this error:

PHP Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id: (request id: 1)' in C:\Inetpub\Venice-Blog\limesurvey\vendor\weberhofer\jsonrpcphp\src\org\jsonrpcphp\JsonRPCClient.php:185
Stack trace:
#0 C:\Inetpub\Venice-Blog\limesurvey\rpc-connect.php(19): org\jsonrpcphp\JsonRPCClient->__call('get_session_key', Array)
#1 C:\Inetpub\Venice-Blog\limesurvey\rpc-connect.php(19): org\jsonrpcphp\JsonRPCClient->get_session_key('admin', 'xxx')
#2 {main}
thrown in C:\Inetpub\Venice-Blog\limesurvey\vendor\weberhofer\jsonrpcphp\src\org\jsonrpcphp\JsonRPCClient.php on line 185

Any ideas? I think the jsonrpc client package was correctly installed (and found by limesurvey). The user / password combo is correct.

I'm running Version 2.06+ Build 150911

Thanks,
Tom

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 years 8 months ago #126587 by mellorine
I got the same error when I forgot to enable JSON-RPC in Global Settings. Are you sure you enabled it? Just a thought.

"Go to Global settings, choose the tab 'Services' and select one of the two RPC services (XML-RPC or JSON-RPC) service."
The following user(s) said Thank You: ashna

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago - 3 years 8 months ago #126593 by tvanover
I've found it. base url was wrong (does that mean the example code is wrong, or is it a windows <> unix thing ,

anyway, this is what baseurl should like for me:

xxx.example.org/limesurvey/index.php?r=admin/remotecontrol
Last edit: 3 years 8 months ago by DenisChenu. Reason: example.org is done for this

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #126614 by holch
Well, Windows doesn't have url rewriting via htaccess i guess?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #126629 by DenisChenu
The url shown in your admin GUI is this one or not ?

If the url shown is false : please report a bug

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

Please Log in or Create an account to join the conversation.

More
1 month 1 day ago #184510 by bes1252
make sure you have http :// or https:// to your base_url (in my case this was the error)

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!