- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
limesurvey api add_participants method cannot add participant
- cetin.sahin
- Topic Author
- Offline
- New Member
Less
More
1 year 7 months ago #231188
by cetin.sahin
limesurvey api add_participants method cannot add participant was created by cetin.sahin
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition
Version 5.3.26+220720
Own server or LimeSurvey hosting: Own server
Survey theme/template: fruity
==================
(Write here your question/remark)
I call limesurvey api add_participants method with c#.
Respose message is equal to request
there is no error. But i can't see adding participant in my survey in portal.
Can you explain how can i call add_participant method step by step via JSONRPC
My c# code :
client.Method = "add_participants";
client.Parameters.Add("sSessionKey", SessionKey);
client.Parameters.Add("iSurveyID", sid);
var Listeklejson = JsonConvert.SerializeObject(surveyParticipantList);
client.Parameters.Add("aParticipantData", Base64Encode(Listeklejson));
client.Parameters.Add("bCreateToken", false);
;
client.Post();
Your LimeSurvey version: LimeSurvey Community Edition
Version 5.3.26+220720
Own server or LimeSurvey hosting: Own server
Survey theme/template: fruity
==================
(Write here your question/remark)
I call limesurvey api add_participants method with c#.
Respose message is equal to request
there is no error. But i can't see adding participant in my survey in portal.
Can you explain how can i call add_participant method step by step via JSONRPC
My c# code :
client.Method = "add_participants";
client.Parameters.Add("sSessionKey", SessionKey);
client.Parameters.Add("iSurveyID", sid);
var Listeklejson = JsonConvert.SerializeObject(surveyParticipantList);
client.Parameters.Add("aParticipantData", Base64Encode(Listeklejson));
client.Parameters.Add("bCreateToken", false);
;
client.Post();
Please Log in to join the conversation.
- cetin.sahin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
1 year 7 months ago #231189
by cetin.sahin
Replied by cetin.sahin on topic limesurvey api add_participants method cannot add participant
List<aParticipantData> Listekle = new List<aParticipantData>();
aParticipantData ekle = new aParticipantData { email = "test@test.com", lastname = "test", firstname = "test", language = "tr" , emailstatus = "OK" };
Listekle.Add(ekle);
aParticipantData ekle = new aParticipantData { email = "test@test.com", lastname = "test", firstname = "test", language = "tr" , emailstatus = "OK" };
Listekle.Add(ekle);
Please Log in to join the conversation.
- jared.kail
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
1 year 6 months ago #231901
by jared.kail
Replied by jared.kail on topic limesurvey api add_participants method cannot add participant
Hi. One thing that tripped me up is that you have to send an array of participants to add_participants and not a single participant. If you are only adding one participant, you still need to send it as a single element of an array. I'm a php coder so my apologies about the syntax difference, but you have to pass this:
and NOT this:
That may not be your issue, but thought I'd throw in what tripped me up just in case.
Code:
[["email"=>"someone@gmail.com", "lastname"=>"Someone", "firstname"=>"Cool"]]
and NOT this:
Code:
["email"=>"someone@gmail.com", "lastname"=>"Someone", "firstname"=>"Cool"]
That may not be your issue, but thought I'd throw in what tripped me up just in case.
Please Log in to join the conversation.
- FherStk
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 2
11 months 3 weeks ago - 11 months 3 weeks ago #241904
by FherStk
Replied by FherStk on topic limesurvey api add_participants method cannot add participant
Same issue here.
This is my code:
var data = "[{'email':'me@example.com','lastname':'Bond','firstname':'James', 'language': 'en', 'emailstatus': 'OK'}]";
this.Client.Method = "add_participants";
this.Client.Parameters.Add("sSessionKey", this.SessionKey);
this.Client.Parameters.Add("iSurveyID", surveyID);
this.Client.Parameters.Add("aParticipantData", data);
this.Client.Post();
I get as response just the same json i sent, but no participant is beeing created within the survey... I tried a lot of combinations (suing base64, setting up the token, etc) but nothing works.
Please, I need help
Thanks,
Fer
This is my code:
var data = "[{'email':'me@example.com','lastname':'Bond','firstname':'James', 'language': 'en', 'emailstatus': 'OK'}]";
this.Client.Method = "add_participants";
this.Client.Parameters.Add("sSessionKey", this.SessionKey);
this.Client.Parameters.Add("iSurveyID", surveyID);
this.Client.Parameters.Add("aParticipantData", data);
this.Client.Post();
I get as response just the same json i sent, but no participant is beeing created within the survey... I tried a lot of combinations (suing base64, setting up the token, etc) but nothing works.
Please, I need help
Thanks,
Fer
Last edit: 11 months 3 weeks ago by FherStk. Reason: Changed \" for ' in order to clarify
Please Log in to join the conversation.
- jared.kail
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
11 months 3 weeks ago - 11 months 3 weeks ago #241914
by jared.kail
Replied by jared.kail on topic limesurvey api add_participants method cannot add participant
Try this instead:
Code:
var data = "[[{'email':'me@example.com','lastname':'Bond','firstname':'James', 'language': 'en', 'emailstatus': 'OK'}]]";
Last edit: 11 months 3 weeks ago by jared.kail.
Please Log in to join the conversation.
- FherStk
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 2
11 months 3 weeks ago #241916
by FherStk
Replied by FherStk on topic limesurvey api add_participants method cannot add participant
I tried this before, but it doesn't work either, the participants list remains empty, and the API response is just the same JSON I sent.
Please Log in to join the conversation.
- FherStk
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 2
11 months 3 weeks ago #241929
by FherStk
Replied by FherStk on topic limesurvey api add_participants method cannot add participant
Solved!
The string containing the json data must be parsed:
var data = "[{'email':'me@example.com','lastname':'Bond','firstname':'James', 'language': 'en', 'emailstatus': 'OK'}]";
WRONG:
this.Client.Parameters.Add("aParticipantData", data);
CORRECT:
this.Client.Parameters.Add("aParticipantData", JArray.Parse(data));
Thanks to everyone for your help
Fher
The string containing the json data must be parsed:
var data = "[{'email':'me@example.com','lastname':'Bond','firstname':'James', 'language': 'en', 'emailstatus': 'OK'}]";
WRONG:
this.Client.Parameters.Add("aParticipantData", data);
CORRECT:
this.Client.Parameters.Add("aParticipantData", JArray.Parse(data));
Thanks to everyone for your help
Fher
The following user(s) said Thank You: DenisChenu
Please Log in to join the conversation.
- cetin.sahin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 months 3 weeks ago #241932
by cetin.sahin
Replied by cetin.sahin on topic limesurvey api add_participants method cannot add participant
I tried all different method . and then i added participants via db connection.
Please Log in to join the conversation.