Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Use add_participants with C#

  • frederic.tahir
  • frederic.tahir's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #212316 by frederic.tahir
Use add_participants with C# was created by frederic.tahir
Hello,

I'm trying since e few hours to add particpants to a survey in my C# program .... the session is OK, the participants are created but without any datas (email, attributes, ...)

Here under the code that 'm testing but i'm not sure at all about the array which contain the participants datas, i didn't found any sample end/or doc ;-)

 string Baseurl = " xxx.limesurvey.net/admin/remotecontrol ";
 JsonRPCclient client = new JsonRPCclient(Baseurl);
 client.Method = "get_session_key";
 client.Parameters.Add("username", "me");
 client.Parameters.Add("password", "mypassword");
 client.Post();
 string SessionKey = client.Response.result.ToString();
 client.ClearParameters();

            if (client.Response.StatusCode == System.Net.HttpStatusCode.OK)
            {
               
                string[,] mtables = new string[,]
                {
                    {"email:myemail1@toto.com","attribute_1:toto"},
                    {"email:myemail2@toto.com","attribute_1:toto"}
                };

                client.Method = "add_participants";
                client.Parameters.Add("sSessionKey", SessionKey);
                client.Parameters.Add("iSurveyID", 2534);
                client.Parameters.Add("aParticipantData", Newtonsoft.Json.Linq.JToken.FromObject(mtables));
                client.Parameters.Add("bCreateToken", false);
                client.Post();

                string retour=client.Response.error;
                System.Net.HttpStatusCode coderetour =client.Response.StatusCode ;
        }

Is someone have already develop in C# this kind of job ?

Thks
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose