Please help us help you and fill where relevant:
Your LimeSurvey version: 5.3.32 and 6.6.5
Own server or LimeSurvey hosting: Own Server Hosting
Survey theme/template: custom
==================
Hello,
I used LSRC2 JSON/RPC 2.0 API to connect to LimeSurvey server and export the participants responses of completed surveys with LimeSurvey version 5.3.32 using code in C# programming language. I used the
export_responses API method, and everything was working as expected.
Recently, I Upgraded to LimeSurvey version 6.6.5, and the same code that expected to return values with
export_responses API, always returned an empty result even if there were surveys completed (Postman return the correct values).
The Programming Language Used: C#
The LimeSurvey Database: SQLServer
Here are the main parts of the code:
Code:
private readonly JsonRpcClient client;
Code:
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.)
The PostAsync function in JsonRpcClient class is as follow:
Code:
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); }
And the class JsonRpcResponse is as follow:
Code:
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; } }
Notice that I had the correct results with the same configuration using Postman.
I tried all possible changes that I found online, but unfortunately I couldn't resolve the issue.
Could you please help me figure out what the issue is.
Thanks for your answer.