Welcome to the LimeSurvey Community Forum

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

add_participants not persisting data to database - yet returns ID and err:null

  • ccc_sdh
  • ccc_sdh's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 weeks ago - 5 years 2 weeks ago #182719 by ccc_sdh
I'm doing some RemoteControl validation to make sure that it can do what we need it to do.

First thing is we need to add participants dynamically, passing in attribute information. The code below appears to successfully make the call. However, it does not return a 'created token' value (bCreateToken is set to true) and trying to displaying the new participants online does not show a new record. ID is always 2 (there is one manually created participant - ID 1)

Any help resolving this would be appreciated. LimeSurvey - Version 3.15.6+190108

Result data:


CODE:
Code:
string Baseurl = $"https://{baseAddress}/index.php/admin/remotecontrol";
            JsonRPCclient client = new JsonRPCclient(Baseurl);
            client.Method = "get_session_key";
            client.Parameters.Add("username", "RemoteControl");
            client.Parameters.Add("password", "*************");
            client.Post();
            string SessionKey = client.Response.result.ToString();
 
            var data = new Dictionary<string, string>();
 
            data.Add("email", "example@example.com");
            data.Add("firstname", "first");
            data.Add("lastname", "last");
            data.Add("emailstatus", "ok");
            data.Add("attribute_1", "44DA8DFF-47CC-49D1-AB3E-70765461D7AF");
 
 
            var serializedData = JsonConvert.SerializeObject(data, Formatting.None);
 
            client.ClearParameters();
 
            if (client.Response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                client.Method = "add_participants";
                client.Parameters.Add("sSessionKey", SessionKey);
                client.Parameters.Add("iSurveyID", 766858);
                client.Parameters.Add("aParticipantData", serializedData);
                client.Parameters.Add("bCreateToken", true);
                client.Post();
            }
 
            client.ClearParameters();
 
            Console.WriteLine("Token: " + client.Response.result.ToString());
            Console.ReadLine();
Last edit: 5 years 2 weeks ago by ccc_sdh.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose