- Posts: 4
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
public void GetParticipantJsonFile(string surveyKey) { var attribute = new string[] { "attribute_1", "attribute_2" }; this.Client.ClearParameters(); this.Client.Method = "list_participants"; this.Client.Parameters.Add("ssessionkey", this.SessionKey); this.Client.Parameters.Add("isurveyid", surveyKey); this.Client.Parameters.Add("aAttributes", JArray.FromObject(attribute)); this.Client.Parameters.Add("bUnused", false); this.Client.Post(); //save in file File.WriteAllBytes(@"C:\Users\xxxx\Desktop\test.json", this.Client.Response.GetFileBlob()); }
public JsonRPCResponse Post() { JObject jobject = new JObject(); jobject.Add(new JProperty("jsonrpc", "2.0")); jobject.Add(new JProperty("id", ++id)); jobject.Add(new JProperty("method", Method)); jobject.Add(new JProperty("params", Parameters)); string PostData = JsonConvert.SerializeObject(jobject); UTF8Encoding encoding = new UTF8Encoding(); byte[] bytes = encoding.GetBytes(PostData); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Method = "POST"; request.ContentType = "application/json"; request.KeepAlive = true; request.ContentLength = bytes.Length; Stream writeStream = request.GetRequestStream(); writeStream.Write(bytes, 0, bytes.Length); writeStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8); Response = new JsonRPCResponse(); Response = JsonConvert.DeserializeObject<JsonRPCResponse>(readStream.ReadToEnd()); Response.StatusCode = response.StatusCode; return Response; }
{ "jsonrpc": "2.0", "id": 2, "method": "list_participants", "params": { "ssessionkey": "xxx", "isurveyid": "xxx", "aAttributes": [ "attribute_1", "attribute_2" ], "bUnused": false } }
{ "tid": "xxx", "token": "xxx", "participant_info": { "firstname": "xxxx", "lastname": "xxx", "email": "xxx@xxx.x" } }
this.Client.Parameters.Add("ssessionkey", this.SessionKey); this.Client.Parameters.Add("isurveyid", surveyKey); this.Client.Parameters.Add("istart", 0); this.Client.Parameters.Add("ilimit", 10); this.Client.Parameters.Add("bUnused", false); this.Client.Parameters.Add("aAttributes", JArray.FromObject(attribute));