How to get the Limesurvey API working in Python

More
1 month 17 hours ago - 1 month 14 hours ago #174102 by gracylayla
gracylayla created the topic: How to get the Limesurvey API working in Python
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: 1 month 14 hours ago by DenisChenu. Reason: Remove direct near spam link

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

More
1 month 16 hours ago #174106 by tpartner
tpartner replied the topic: How to get the Limesurvey API working in Python
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.

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

More
1 month 14 hours ago #174121 by DenisChenu
DenisChenu replied the topic: How to get the Limesurvey API working in Python

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
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!