How to get the Limesurvey API working in Python

More
8 months 6 hours ago - 8 months 3 hours ago #174102 by gracylayla
I'm trying to get the session key from the Limesurvey API using Selenium with Python 2.7 ( mindmajix.com/selenium-with-python-training ) and I'm not getting any results after running my code. I've followed the example in the documentation but still get an error
<p>Error: <type 'exceptions.ValueError'></p>
. My code is as follows:
import urllib
import urllib2
import json
import sys
 
req = urllib2.Request(url='https://testone.limequery.com/index.php/admin/remotecontro,\
                              data='{\"method\":\"get_session_key\",\"params\":[\"admin\",\"Password\"],\"id\":1}')
req.add_header('content-type', 'application/json')
req.add_header('connection', 'Keep-Alive')
 
try:    
    f = urllib2.urlopen(req)
    myretun = f.read()
    j=json.loads(myretun)
    print (j['result'])
except :
        e = sys.exc_info()[0]
        print ( "<p>Error: %s</p>" % e )

Removing the try catch gives me the error ValueError: No JSON object could be decoded
Last edit: 8 months 3 hours ago by DenisChenu. Reason: Remove direct near spam link

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

LimeSurvey Partners
More
8 months 5 hours ago #174106 by tpartner
I know little about Python but it seems to me that the path to remotcontrol is incorrect.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

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

More
8 months 3 hours ago #174121 by DenisChenu

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.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!