- Posts: 7
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
private readonly JsonRpcClient client;
var exportResponsesRequest = new JsonRpcRequest(){ RequestId = ++requestId, Method = "export_responses", Parameters = new Dictionary<string, object> { ["sSessionKey"] = sessionKey, ["iSurveyID"] = surveyId, ["sDocumentType"] = "json", ["sLanguageCode"] = language, ["sCompletionStatus"] = completionStatus, ["sHeadingType"] = headingType, ["sResponseType"] = responseType, ["iFromResponseID"] = fromResponseID, ["iToResponseID"] = toResponseID },};var response = await client.PostAsync(exportResponsesRequest);try{ return DecodeBase64(response.Result?.ToString());}catch{ // If string isn't base64, it likely contains an error message.)
public async Task<JsonRpcResponse> PostAsync(JsonRpcRequest requestObject) { var httpClient = new HttpClient(); string requestJson = JsonSerializer.Serialize(requestObject); var stringContent = new StringContent(requestJson, Encoding.UTF8, "application/json"); var httpResponse = await httpClient.PostAsync(url, stringContent); var resultString = await httpResponse.Content.ReadAsStringAsync(); return ProcessResponseObject(resultString, httpResponse.StatusCode, requestObject); }
public class JsonRpcResponse { [JsonPropertyName("id")] public int Id { get; set; } [JsonPropertyName("result")] public object Result { get; set; } [JsonPropertyName("error")] public string Error { get; set; } public HttpStatusCode StatusCode { get; set; } }
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.