- Posts: 72
- Thank you received: 17
Ask the community, share ideas, and connect with other LimeSurvey users!
def list_participants(self, sid, iStart=0, iLimit=100, bUnused='false', aAttributes='false', aConditions=array()): data = """ { "id" : 1, "method":"list_participants", "params": { "sSessionKey": "%s", "iSurveyID": %s, "iStart": %s, "iLimit": %s, "bUnused": "%s", "aAttributes": "%s", "aConditions": "%s" } } """ % (self.session_key, sid, iStart, iLimit, bUnused, aAttributes, aConditions) return self._getJSON(data)['result']
usesleft'=>$token->attributes['usesleft']
lime.list_participants(sid, iStart=0, iLimit=10000, bUnused='false', aAttributes='usesleft', aConditions=None)
Deusdeorum wrote: Same goes for the R case, it seems like i'm missing something..
Adding the following to the list_participants remotecontrol_handle.php will work, but it still feels like i'm calling the API wrong.
Adding:under the list_participants in remotecontrol_handle.php will return usesleft as default, but i'm sure i'm calling the API wrongCode:usesleft'=>$token->attributes['usesleft']
In the python glue case:
Calling the API:this will return the defaults: 'participant_info.email', 'participant_info.firstname', 'participant_info.lastname', 'tid', 'token'Code:lime.list_participants(sid, iStart=0, iLimit=10000, bUnused='false', aAttributes='usesleft', aConditions=None)
usesleft'=>$token->attributes['usesleft']
frederikprijck wrote: I got it working in C# => prntscr.com/ar9ykj
Could you share your HTTP headers + body ?
{"method":"list_participants", "params":{ "id":1, "sSessionKey":"xxxx", "iSurveyID":111, "iStart":0, "iLimit":100000, "bUnused":false, "aAttributes":["language","completed","usesleft"], "aConditions":{"usesleft":"0"} } }
frederikprijck wrote: Hi,
I'm not aware of the python project. But the Remote API is accessed using HTTP, looking at the linked Github project I can tell it's also calling the RPC over HTTP.
To ensure everything is sent to the RPC as expected, it's a good idea to inspect the HTTP headers and body (this is generally a good idea when doing HTTP Requests).
I use fiddler ( www.telerik.com/fiddler ) for this but I'm pretty sure there will be other tools around which can sort you out.
The next thing you should do is make your call to the RPC and make sure it is recorded.
Now you can inspect the body and ensure it has a format as the screenshots attached:
This is the JSON extract of the body of the Http Post RequestCode:{"method":"list_participants", "params":{ "id":1, "sSessionKey":"xxxx", "iSurveyID":111, "iStart":0, "iLimit":100000, "bUnused":false, "aAttributes":["language","completed","usesleft"], "aConditions":{"usesleft":"0"} } }
This is copied from my succesful request.
Apart from inspecting the Request, you can also inspect the response. (See the other attached screenshot)
Here you can see that I succesfully got the 3 extra fields (usesleft, completed and language) for each token.
Also, which version of LimeSurvey are you using ?
def list_participants(): req = urllib2.Request(url='https://www.myurl.com/index.php/admin/remotecontrol',\ data='{\"method\":\"list_participants\",\"params\":{\"sSessionKey\":\"MYSESSIONKEY\",\"iSurveyID\":MYSID,\"iStart\":0,\"iLimit\":200,\"bUnused\":\"True\",\"aAttributes\":\"usesleft\",\"aConditions\":\"\"},\"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 return j['result'] except : e = sys.exc_info()[0] print ( "<p>Error: %s</p>" % e )